From d9adfc53a370432ef72c56203823100b7e8d159b Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Wed, 29 May 2024 15:39:44 +0800 Subject: [PATCH] test:screenshot --- jest-setup.js | 18 ++++++++++-------- pages/pages.test.js | 2 +- pages/ucenter/settings/settings.test.js | 2 +- pages/ucenter/ucenter.test.js | 2 +- .../pages/userinfo/userinfo.test.js | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/jest-setup.js b/jest-setup.js index e3e98d9..3259582 100644 --- a/jest-setup.js +++ b/jest-setup.js @@ -1,16 +1,18 @@ const path = require("path"); const fs = require("fs"); -const {configureToMatchImageSnapshot} = require('jest-image-snapshot'); +const { + configureToMatchImageSnapshot +} = require('jest-image-snapshot'); let saveImageSnapshotDir = process.env.saveImageSnapshotDir || path.join(__dirname, '__snapshot__'); expect.extend({ - // toMatchImageSnapshot: configureToMatchImageSnapshot({ - // customSnapshotIdentifier(args) { - // return args.currentTestName.replace(/\//g, "-").replace(" ", "-"); - // }, - // customSnapshotsDir: process.env.saveImageSnapshotDir, - // customDiffDir: path.join(saveImageSnapshotDir, "diff"), - // }), + toMatchImageSnapshot: configureToMatchImageSnapshot({ + customSnapshotIdentifier(args) { + return args.currentTestName.replace(/\//g, "-").replace(" ", "-"); + }, + customSnapshotsDir: process.env.saveImageSnapshotDir, + customDiffDir: path.join(saveImageSnapshotDir, "diff"), + }), toSaveSnapshot, toSaveImageSnapshot, }); diff --git a/pages/pages.test.js b/pages/pages.test.js index fb045e4..3010dde 100644 --- a/pages/pages.test.js +++ b/pages/pages.test.js @@ -26,7 +26,7 @@ describe('page screenshot test', () => { console.log("page screenshot test finish"); }); test.each(pages)('%s', async () => { - const image = await program.screenshot({deviceShot:true,fullPage:true}); + const image = await program.screenshot(); expect(image).toSaveImageSnapshot(); await page.waitFor(500); }) diff --git a/pages/ucenter/settings/settings.test.js b/pages/ucenter/settings/settings.test.js index 8c1eb4d..fef5f44 100644 --- a/pages/ucenter/settings/settings.test.js +++ b/pages/ucenter/settings/settings.test.js @@ -32,7 +32,7 @@ describe('settings', () => { } }) it('screenshot', async () => { - const image = await program.screenshot({deviceShot:true,fullPage:true}); + const image = await program.screenshot(); expect(image).toSaveImageSnapshot(); await page.waitFor(500); }) diff --git a/pages/ucenter/ucenter.test.js b/pages/ucenter/ucenter.test.js index 5cf1e11..00d4de2 100644 --- a/pages/ucenter/ucenter.test.js +++ b/pages/ucenter/ucenter.test.js @@ -57,7 +57,7 @@ describe('ucenter', () => { } }) it('screenshot', async () => { - const image = await program.screenshot({deviceShot:true,fullPage:true}); + const image = await program.screenshot(); expect(image).toSaveImageSnapshot(); await page.waitFor(500); }) diff --git a/uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js b/uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js index f2b1f3f..43cca7a 100644 --- a/uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js +++ b/uni_modules/uni-id-pages/pages/userinfo/userinfo.test.js @@ -30,7 +30,7 @@ describe('userinfo', () => { expect(userInfo.nickname).toBe(nickname) }) it('screenshot', async () => { - const image = await program.screenshot({deviceShot:true,fullPage:true}); + const image = await program.screenshot(); expect(image).toSaveImageSnapshot(); await page.waitFor(500); }) -- GitLab