userinfo.test.js 1.9 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.io/collocation/auto/hbuilderx-extension/index
A
Anne_LXM 已提交
2
const PAGE_PATH = '/uni_modules/uni-id-pages/pages/userinfo/userinfo'
Anne_LXM's avatar
Anne_LXM 已提交
3
jest.setTimeout(30000);
A
Anne_LXM 已提交
4
describe('userinfo',() => {
Anne_LXM's avatar
Anne_LXM 已提交
5
	let page,hasLogin;
study夏羽's avatar
study夏羽 已提交
6
	beforeAll(async () => {
A
Anne_LXM 已提交
7
		page = await program.navigateTo(PAGE_PATH)
A
Anne_LXM 已提交
8
		await page.waitFor("view")
Anne_LXM's avatar
Anne_LXM 已提交
9 10 11 12 13 14
    hasLogin = await page.callMethod('hasLoginTest')
    console.log("登录状态",hasLogin)
    if(!hasLogin){
      console.log("未登录测试失败")
      return
    }
study夏羽's avatar
study夏羽 已提交
15
	});
Anne_LXM's avatar
Anne_LXM 已提交
16 17 18 19
	it("昵称", async () => {
		const nickname = "数字天堂DCloud" + Math.round(Math.random() * 10);
		await page.waitFor(300)
		await page.callMethod("setNickname", nickname)
A
Anne_LXM 已提交
20
	})
Anne_LXM's avatar
Anne_LXM 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
	it("头像", async () => {
		const imgs = [
			"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-52b18b34-3a3e-4861-89a0-c362c7634787/5105c383-8d83-4f40-938e-7c32c5983f8d.png",
			"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-52b18b34-3a3e-4861-89a0-c362c7634787/61869c72-3117-4ea4-8d6d-ebb67617c7d9.jpg",
			"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-52b18b34-3a3e-4861-89a0-c362c7634787/558cde0a-b514-4de7-8c7d-1d6b733f9440.png"]
			
		const avatar_file = {
			url:imgs[Math.floor(Math.random()*imgs.length)]
		}
		console.log("avatar_file: ",avatar_file);
		console.log("process.env.UNI_PLATFORM: ",process.env.UNI_PLATFORM);
		// if (process.env.UNI_PLATFORM != "mp-weixin") {
		// 	const avatarCom = await page.$('.avatar')
		// 	console.log("avatarCom: ",avatarCom);
		// 	const elBox = await avatarCom.$('.box')
		// 	console.log("elBox: ",elBox);
		// 	// const elBox = await page.$('.box')
		// 	await elBox.callMethod('setAvatarFile',avatar_file)
		// 	await elBox.waitFor(500)
		// }
	})
	// it("screenshot", async () => {
	// 	await program.screenshot({
	// 		path: "static/screenshot/userinfo.png" // 默认项目根目录
	// 	})
	// 	await page.waitFor(500)
	// })
study夏羽's avatar
study夏羽 已提交
48
});