about.test.js 1.3 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start

describe('pages/ucenter/about/about.vue', () => {
	let page
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
7 8 9 10 11 12 13 14
		try {
			page = await program.navigateTo('/pages/ucenter/about/about')
			console.log("page: ",page);
			await page.waitFor(500)
		} catch (e) {
			console.log("e: ",e);
		}
		
study夏羽's avatar
study夏羽 已提交
15 16
	})

study夏羽's avatar
study夏羽 已提交
17
	it('about', async () => {
study夏羽's avatar
study夏羽 已提交
18
		// expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
19
		const getData = await page.data('about')
study夏羽's avatar
study夏羽 已提交
20 21
		console.log("getData: ",getData);
		// expect(getData.appName).toBe('uni-starter')
study夏羽's avatar
study夏羽 已提交
22 23
	})

study夏羽's avatar
study夏羽 已提交
24
	it('screenshot', async () => {
study夏羽's avatar
study夏羽 已提交
25
		if (process.env.UNI_PLATFORM == "h5") {
study夏羽's avatar
测试  
study夏羽 已提交
26 27 28
			const image = await program.screenshot({
				path: "static/screenshot/about-h5.png" // 默认项目根目录
			})
study夏羽's avatar
study夏羽 已提交
29 30 31
			console.log("image: ",image);
		} else if (process.env.UNI_PLATFORM == "app-plus") {
			console.log('app-plus');
study夏羽's avatar
测试  
study夏羽 已提交
32
			await program.screenshot({
study夏羽's avatar
study夏羽 已提交
33
				path: "static/screenshot/about-app.png"
study夏羽's avatar
测试  
study夏羽 已提交
34
			})
study夏羽's avatar
study夏羽 已提交
35 36
		} else if (process.env.UNI_PLATFORM == "mp-weixin") {
			console.log('mp-weixin');
study夏羽's avatar
测试  
study夏羽 已提交
37
			await program.screenshot({
study夏羽's avatar
study夏羽 已提交
38
				path: "static/screenshot/about-mp.png"
study夏羽's avatar
测试  
study夏羽 已提交
39 40
			})
		}
study夏羽's avatar
study夏羽 已提交
41

study夏羽's avatar
study夏羽 已提交
42
	})
study夏羽's avatar
study夏羽 已提交
43

study夏羽's avatar
study夏羽 已提交
44 45

	it('隐私政策协议-点击跳转', async () => {
study夏羽's avatar
study夏羽 已提交
46 47 48 49 50 51 52
		await page.callMethod('navigateTo', {
			url: "https://ask.dcloud.net.cn/protocol.html",
			title: "用户服务条款"
		})
	})

});