index.test.js 1.7 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/login-page/index/index.vue', () => {

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

study夏羽's avatar
study夏羽 已提交
16
	it('smsCode-login', async () => {
study夏羽's avatar
study夏羽 已提交
17 18
		const perPage = await page.$('.content')
		const getTitle = await perPage.$('.title')
study夏羽's avatar
study夏羽 已提交
19 20
		// console.log(await getTitle.text());
		
study夏羽's avatar
study夏羽 已提交
21
		if ((await program.currentPage()).path == 'pages/ucenter/login-page/index/index') {
study夏羽's avatar
study夏羽 已提交
22 23
			console.log(await getTitle.text(),"1-------------");
			// expect(await getTitle.text()).toBe('登录后即可展示自己')
study夏羽's avatar
study夏羽 已提交
24 25 26 27 28 29 30 31 32 33
			
			const setInput = await page.setData({
				"phone": '17769516019',
				"agree": true,
				// "type":"smsCode"
			})
			await page.waitFor(300)
			console.log(await page.data('phone'), "phone----------");
			console.log(await page.data('agree'), "agree-----------");
			console.log(await page.data('type'), "type----------");
study夏羽's avatar
study夏羽 已提交
34 35 36 37 38 39 40 41
			
			const agreeTrue = await page.waitFor(async () => {
				return await page.data('agree')
			})
			
			await page.callMethod('sendShortMsg')
			await page.waitFor(300)
			//pages/ucenter/login-page/phone-code/phone-code
study夏羽's avatar
study夏羽 已提交
42 43
		}
		
study夏羽's avatar
study夏羽 已提交
44
		if ((await program.currentPage()).path == 'pages/ucenter/login-page/pwd-login/pwd-login') {
study夏羽's avatar
study夏羽 已提交
45 46
			console.log(await getTitle.text(),"2-------------");
			// expect(await getTitle.text()).toBe('用户名密码登录')
study夏羽's avatar
study夏羽 已提交
47
		}
study夏羽's avatar
study夏羽 已提交
48
		console.log("currentPage:---------- ",await program.currentPage());
study夏羽's avatar
study夏羽 已提交
49 50
	})
})
study夏羽's avatar
study夏羽 已提交
51 52 53 54 55