提交 27c638bd 编写于 作者: A Anne_LXM

update test

上级 5a08267e
......@@ -9,14 +9,13 @@ describe('grid', () => {
})
it('检测宫格', async () => {
hasLogin = await page.data('hasLogin')
console.log("hasLogin", hasLogin)
let gridList = await page.data('gridList')
console.log("gridList", gridList)
console.log("gridList", hasLogin,gridList.length)
expect(gridList.length).toBe(9)
})
it('点击宫格', async () => {
const perPage = await page.$$('.grid-item-box')
console.log("perPage", perPage)
console.log("perPage", perPage.length)
for (var i = 0; i < perPage.length; i++) {
await perPage[i].tap()
await page.waitFor(300)
......
......@@ -127,7 +127,7 @@
// });
//默认h5端不获取定位
// #ifndef H5
if(isTest){
if(this.isTest){
let location = await gps.getLocation({
geocode: true
})
......
......@@ -11,9 +11,7 @@ describe('list', () => {
beforeAll(async () => {
page = await program.switchTab(PAGE_PATH)
await page.waitFor('view')
console.log('page: ',page);
await page.setData({'isTest':true})
console.log('isTest',await page.data({'isTest':true}));
})
it('检测标题', async () => {
expect.assertions(1);
......
......@@ -3,16 +3,20 @@
const PAGE_PATH = '/pages/ucenter/about/about'
describe('about', () => {
let page,isWX;
beforeAll(async () => {
isWX = process.env.UNI_PLATFORM === "mp-weixin"
if(!isWX){
isWX = process.env.UNI_PLATFORM === "mp-weixin"
if(isWX){
it('微信平台不支持', async () => {
expect(1).toBe(1)
})
return
}else{
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
}
})
it('appName', async () => {
if(isWX)return
expect.assertions(1);
expect((await page.data('about')).appName).toBe('uni-starter')
})
})
it('appName', async () => {
expect.assertions(1);
expect((await page.data('about')).appName).toBe('uni-starter')
})
}
});
......@@ -2,14 +2,12 @@ jest.setTimeout(20000);
const PAGE_PATH = '/pages/ucenter/ucenter'
describe('ucenter', () => {
let page,uniToken,platform;
platform = process.env.UNI_PLATFORM
beforeAll(async () => {
try{
page = await program.switchTab(PAGE_PATH)
await page.waitFor('view')
console.log('page: ',page);
console.log('pageStack: ',await program.pageStack());
uniToken = await program.callUniMethod('getStorageSync', 'uni_id_token')
platform = process.env.UNI_PLATFORM
console.log("uniToken: ",platform,uniToken);
}catch(err){
console.log('err: ',err);
......@@ -22,38 +20,38 @@ describe('ucenter', () => {
})
it('列表', async () => {
const getUcenterList = await page.data('ucenterList')
if(platform.startsWith("app") || platform === "h5"){
expect(getUcenterList.length).toBe(3)
}else if(platform === "mp-weixin"){
expect(getUcenterList.length).toBe(2)
}
})
it('普通签到', async () => {
if(!uniToken)return;
if(platform.startsWith("app")){
await page.callMethod('signInByAd')
await page.waitFor(1000)
await page.callMethod('share')
// await program.screenshot({
// path: "static/screenshot/sign-app.png"
// })
if(platform === "mp-weixin"){
expect(getUcenterList).toHaveLength(2);
}else{
await page.callMethod('signIn')
}
})
it('我的积分', async () => {
if(!uniToken)return;
const getScoreRes = await page.callMethod('getScore')
console.log('getScoreRes: ',getScoreRes);
await page.waitFor(1000)
if (getScoreRes.score) {
expect.assertions(2);
expect(getScoreRes.score).not.toBeUndefined();
expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
} else {
console.log("签到失败");
expect(getUcenterList).toHaveLength(3);
}
})
if(uniToken){
it('普通签到', async () => {
if(platform.startsWith("app")){
await page.callMethod('signInByAd')
await page.waitFor(1000)
await page.callMethod('share')
// await program.screenshot({
// path: "static/screenshot/sign-app.png"
// })
}else{
await page.callMethod('signIn')
}
})
it('我的积分', async () => {
const getScoreRes = await page.callMethod('getScore')
console.log('getScoreRes: ',getScoreRes);
await page.waitFor(1000)
if (getScoreRes.score) {
expect.assertions(2);
expect(getScoreRes.score).not.toBeUndefined();
expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
} else {
console.log("签到失败");
}
})
}
// it('screenshot',async()=>{
// await program.screenshot({
// path: "static/screenshot/ucenter.png"
......
......@@ -24,7 +24,7 @@ describe('login-withpwd', () => {
const resLogin = await page.callMethod('pwdLogin')
console.log("resLogin: ", resLogin);
expect.assertions(1);
switch (resLogin.errCode){
case 0:
expect(resLogin.uid).toHaveLength(24);
......@@ -80,7 +80,6 @@ describe('login-withpwd', () => {
console.log(await program.currentPage());
break;
}
console.log('login-end')
await page.waitFor(300)
})
......
......@@ -20,7 +20,7 @@ describe('register', () => {
})
const resLogin = await page.callMethod('submit')
console.log("resLogin: ", resLogin);
expect.assertions(1);
switch (resLogin.errCode) {
case 0:
console.log('注册成功')
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.io/collocation/auto/hbuilderx-extension/index
const PAGE_PATH = '/uni_modules/uni-id-pages/pages/userinfo/userinfo'
describe('userinfo', () => {
describe('userinfo',() => {
let page,uniToken;
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor("view")
console.log("page: ",page);
console.log("pageStack: ",await program.pageStack());
uniToken = await program.callUniMethod('getStorageSync', 'uni_id_token')
console.log("uniToken: ",uniToken);
console.log("pageStack: ",await program.pageStack());
});
it("昵称", async () => {
if(!uniToken)return;
const nickname = "数字天堂DCloud" + Math.round(Math.random() * 10);
await page.waitFor(300)
await page.callMethod("setNickname", nickname)
})
it("头像", async () => {
if(!uniToken)return;
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)
// }
})
if(uniToken){
it("昵称", async () => {
const nickname = "数字天堂DCloud" + Math.round(Math.random() * 10);
await page.waitFor(300)
await page.callMethod("setNickname", nickname)
})
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 () => {
if(!uniToken)return;
await program.screenshot({
path: "static/screenshot/userinfo.png" // 默认项目根目录
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册