From 281493729a424796b6aea60a5da29632a8d701be Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Wed, 19 Jun 2024 17:48:05 +0800 Subject: [PATCH] =?UTF-8?q?test(getCurrentPages):=20=E8=A1=A5=E5=85=85=20t?= =?UTF-8?q?oSaveImageSnapshot=20=E8=87=AA=E5=AE=9A=E4=B9=89=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get-current-pages.test.js | 60 ++++++++++--------- ...ge-style-disable-pull-down-refresh.test.js | 8 ++- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/pages/API/get-current-pages/get-current-pages.test.js b/pages/API/get-current-pages/get-current-pages.test.js index 7c0564fe..7e377cb8 100644 --- a/pages/API/get-current-pages/get-current-pages.test.js +++ b/pages/API/get-current-pages/get-current-pages.test.js @@ -1,28 +1,28 @@ -const HOME_PAGE_PATH = '/pages/tabBar/component' -const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages' - -describe('getCurrentPages', () => { - let page - it('getCurrentPages', async () => { - // web 端等待应用首页加载完成 - if (process.env.uniTestPlatformInfo.startsWith('web')) { - const waitTime = process.env.uniTestPlatformInfo.includes('safari') ? - 5000 : - 3000 - await new Promise((resolve) => { - setTimeout(() => { - resolve() - }, waitTime) - }) - } - page = await program.switchTab(HOME_PAGE_PATH) - await page.waitFor(1000) - page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) - await page.callMethod('_getCurrentPages') - await page.waitFor(200) - const data = await page.data() - expect(data.checked).toBe(true) +const HOME_PAGE_PATH = '/pages/tabBar/component' +const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages' + +describe('getCurrentPages', () => { + let page + it('getCurrentPages', async () => { + // web 端等待应用首页加载完成 + if (process.env.uniTestPlatformInfo.startsWith('web')) { + const waitTime = process.env.uniTestPlatformInfo.includes('safari') ? + 5000 : + 3000 + await new Promise((resolve) => { + setTimeout(() => { + resolve() + }, waitTime) + }) + } + page = await program.switchTab(HOME_PAGE_PATH) + await page.waitFor(1000) + page = await program.navigateTo(PAGE_PATH) + await page.waitFor(1000) + await page.callMethod('_getCurrentPages') + await page.waitFor(200) + const data = await page.data() + expect(data.checked).toBe(true) }) it('page-style', async () => { page = await program.navigateTo(PAGE_PATH) @@ -47,7 +47,9 @@ describe('getCurrentPages', () => { await page.callMethod('startPullDownRefresh') await page.waitFor(500) const image2 = await program.screenshot({fullPage: true}); - expect(image2).toSaveImageSnapshot(); + expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() { + return 'get-current-pages-test-js-get-current-pages-page-style-before-set-page-style' + }}); await page.waitFor(3500) await page.callMethod('setPageStyle', { @@ -57,6 +59,8 @@ describe('getCurrentPages', () => { await page.callMethod('startPullDownRefresh') await page.waitFor(500) const image3 = await program.screenshot({fullPage: true}); - expect(image3).toSaveImageSnapshot(); - }) + expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() { + return 'get-current-pages-test-js-get-current-pages-page-style-after-set-page-style' + }}); + }) }) diff --git a/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.test.js b/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.test.js index 22f5f225..a440c56c 100644 --- a/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.test.js +++ b/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.test.js @@ -27,7 +27,9 @@ describe('getCurrentPages', () => { const image3 = await program.screenshot({ fullPage: true }); - expect(image3).toSaveImageSnapshot(); + expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() { + return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-before-set-page-style' + }}); await page.waitFor(3500) @@ -39,7 +41,9 @@ describe('getCurrentPages', () => { const image2 = await program.screenshot({ fullPage: true }); - expect(image2).toSaveImageSnapshot(); + expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() { + return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-after-set-page-style' + }}); }) }) -- GitLab