settings.test.js 1.2 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1
// uniapp自动化测试教程: https://uniapp-test.dcloud.net.cn/docs/testcase/start
Anne_LXM's avatar
Anne_LXM 已提交
2
jest.setTimeout(30000);
A
Anne_LXM 已提交
3 4
const PAGE_PATH = '/pages/ucenter/settings/settings'
describe('settings', () => {
Anne_LXM's avatar
Anne_LXM 已提交
5
	let page,hasLogin;
study夏羽's avatar
study夏羽 已提交
6
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
7
		try {
A
Anne_LXM 已提交
8
			page = await program.navigateTo(PAGE_PATH)
A
Anne_LXM 已提交
9
			await page.waitFor('view')
Anne_LXM's avatar
Anne_LXM 已提交
10 11 12 13 14 15
      hasLogin = await page.callMethod('hasLoginTest')
      console.log("登录状态",hasLogin)
      if(!hasLogin){
        console.log("未登录测试失败")
        return
      }
study夏羽's avatar
study夏羽 已提交
16 17
		} catch (err) {
			console.log("err: ",err);
study夏羽's avatar
study夏羽 已提交
18
		}
study夏羽's avatar
study夏羽 已提交
19
	})
study夏羽's avatar
study夏羽 已提交
20
	it('settings', async () => {
21
		if (process.env.UNI_PLATFORM.startsWith("app")) {
study夏羽's avatar
study夏羽 已提交
22
			await page.callMethod('clearTmp')
study夏羽's avatar
study夏羽 已提交
23
			const pushRes = await page.data('pushIsOn')
A
Anne_LXM 已提交
24
			if (pushRes == "wait") {await page.callMethod('pushServer.off')}
study夏羽's avatar
study夏羽 已提交
25 26
		}else{
			const el = await page.$('.content')
A
Anne_LXM 已提交
27
			await page.waitFor('view')
study夏羽's avatar
study夏羽 已提交
28
			expect.assertions(1);
A
Anne_LXM 已提交
29
			expect((await el.$$('.mt10')).length).toBe(2)
study夏羽's avatar
study夏羽 已提交
30 31
		}
	})
A
Anne_LXM 已提交
32
	it('退出登录', async () => {
Anne_LXM's avatar
Anne_LXM 已提交
33 34 35
    const bottomEl = await page.$('.bottom-back-text')
    console.log('bottom-back-text',bottomEl,await bottomEl.text())
    expect(await bottomEl.text()).toBe('退出登录')
A
Anne_LXM 已提交
36
		await page.callMethod('changeLoginState')
Anne_LXM's avatar
Anne_LXM 已提交
37
		await page.waitFor(1000)
A
Anne_LXM 已提交
38
	})
study夏羽's avatar
study夏羽 已提交
39
});