From 24fb15972d91d93b1aa8a6e2dbd44f90cad2426c Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Mon, 31 Jul 2023 17:17:51 +0800 Subject: [PATCH] test: configure screenshot directory --- jest-setup.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) mode change 100755 => 100644 jest-setup.js diff --git a/jest-setup.js b/jest-setup.js old mode 100755 new mode 100644 index c7546a3c..8ddb4e3d --- a/jest-setup.js +++ b/jest-setup.js @@ -1,7 +1,18 @@ -const { - toMatchImageSnapshot -} = require('jest-image-snapshot'); - -expect.extend({ - toMatchImageSnapshot +const path = require('path'); +const { + configureToMatchImageSnapshot +} = require('jest-image-snapshot'); + +const hbuilderx_version = process.env.HX_Version +const uniTestPlatformInfo = process.env.uniTestPlatformInfo ? process.env.uniTestPlatformInfo.replace(/\s/g,'_') : '' +const folderName = `__image_snapshots__/${hbuilderx_version}/__${uniTestPlatformInfo}__` + +expect.extend({ + toMatchImageSnapshot: configureToMatchImageSnapshot({ + customSnapshotIdentifier(args) { + return args.currentTestName.replace(/\//g, '-').replace(' ', '-'); + }, + customSnapshotsDir: path.join(__dirname, folderName), + customDiffDir: path.join(__dirname, `${folderName}/`, 'diff'), + }), }); \ No newline at end of file -- GitLab