From 30b064342f7d8f9394c7a19709327f44b029534f Mon Sep 17 00:00:00 2001 From: Anne_LXM <54163582+anne-lxm@users.noreply.github.com> Date: Fri, 22 Dec 2023 12:09:16 +0800 Subject: [PATCH] update test --- package.json | 15 +++++++++------ pages/grid/grid.test.js | 1 - pages/list/list.test.js | 4 ++-- pages/pages.test.js | 3 ++- pages/ucenter/ucenter.test.js | 9 ++++----- pages/ucenter/ucenter.vue | 2 +- .../pages/login/login-withpwd.test.js | 12 +++++------- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 818e2e6..ca68da7 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "version": "2.1.8", "description": "云端一体应用快速开发基本项目模版", "keywords": [ - "login", - "登录", - "搜索", - "uni-id实例", - "留言板" - ], + "login", + "登录", + "搜索", + "uni-id实例", + "留言板" + ], "repository": "https://gitcode.net/dcloud/uni-starter", "engines": { "HBuilderX": "^3.2.6" @@ -83,5 +83,8 @@ }, "dependencies": { "qrcodejs2": "^0.0.2" + }, + "devDependencies": { + "jest-image-snapshot": "^6.4.0" } } diff --git a/pages/grid/grid.test.js b/pages/grid/grid.test.js index 26de6bb..863c410 100644 --- a/pages/grid/grid.test.js +++ b/pages/grid/grid.test.js @@ -14,7 +14,6 @@ describe('pages/grid/grid.vue', () => { }) it('点击宫格', async () => { const perPage = await page.$$('.grid-item-box') - // console.log('perPage: ',perPage); expect(perPage.length).toBe(3) for (var i = 0; i < perPage.length; i++) { await perPage[i].tap() diff --git a/pages/list/list.test.js b/pages/list/list.test.js index 383d9e7..45474c8 100644 --- a/pages/list/list.test.js +++ b/pages/list/list.test.js @@ -6,10 +6,10 @@ describe('pages/list/list.vue', () => { if(process.env.UNI_PLATFORM === "mp-weixin"){await page.waitFor(2000)} }) it('检测标题', async () => { - // expect.assertions(1); + expect.assertions(1); const getTitle = await page.data('dataList') console.log('getTitle: ',getTitle); - // expect((await page.data('dataList')).title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务') + expect((await page.data('dataList')).title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务') }) it('点击搜索跳转', async () => { await page.callMethod('searchClick') diff --git a/pages/pages.test.js b/pages/pages.test.js index 3939049..6424fe0 100644 --- a/pages/pages.test.js +++ b/pages/pages.test.js @@ -1,8 +1,9 @@ let pageIndex = 0 const pages = [ + '/uni_modules/uni-id-pages/pages/login/login-withoutpwd', '/pages/ucenter/settings/settings', '/pages/ucenter/ucenter', - '/uni_modules/uni-id-pages/pages/login/login-withoutpwd' + '/uni_modules/uni-id-pages/pages/userinfo/userinfo', ] let page; diff --git a/pages/ucenter/ucenter.test.js b/pages/ucenter/ucenter.test.js index 0299b10..e9d0290 100644 --- a/pages/ucenter/ucenter.test.js +++ b/pages/ucenter/ucenter.test.js @@ -57,13 +57,12 @@ describe('pages/ucenter/ucenter.vue', () => { it('我的积分', async () => { if(!uniToken)return; const getScoreRes = await page.callMethod('getScore') - let scoreInfo = getScoreRes && getScoreRes.result.data[0] - console.log('scoreInfo: ',scoreInfo); + console.log('getScoreRes: ',getScoreRes); await page.waitFor(500) - if (scoreInfo) { + if (getScoreRes.score) { expect.assertions(2); - expect(scoreInfo.score).not.toBeUndefined(); - expect(scoreInfo.balance).toBeGreaterThanOrEqual(scoreInfo.score); + expect(getScoreRes.score).not.toBeUndefined(); + expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score); } else { console.log("签到失败"); } diff --git a/pages/ucenter/ucenter.vue b/pages/ucenter/ucenter.vue index 03a984f..dd5a7d7 100644 --- a/pages/ucenter/ucenter.vue +++ b/pages/ucenter/ucenter.vue @@ -269,7 +269,7 @@ title: msg, icon: 'none' }); - return res + return res.result.data[0] }).finally((err) => { uni.hideLoading() return err diff --git a/uni_modules/uni-id-pages/pages/login/login-withpwd.test.js b/uni_modules/uni-id-pages/pages/login/login-withpwd.test.js index a753ff3..13b5ee6 100644 --- a/uni_modules/uni-id-pages/pages/login/login-withpwd.test.js +++ b/uni_modules/uni-id-pages/pages/login/login-withpwd.test.js @@ -6,11 +6,11 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => { page = await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd') await page.waitFor('view') }); - it('screenshot',async()=>{ - const image = await program.screenshot(); - expect(image).toMatchImageSnapshot(); - await page.waitFor(500); - }) + // it('screenshot',async()=>{ + // const image = await program.screenshot(); + // expect(image).toMatchImageSnapshot(); + // await page.waitFor(500); + // }) it('账号密码登录', async () => { await page.setData({ "username": "DCloud", @@ -28,8 +28,6 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => { const resLogin = await page.callMethod('pwdLogin') console.log("resLogin: ", resLogin); - - switch (resLogin.errCode){ case 0: console.log('登录成功') -- GitLab