diff --git a/jest-setup.js b/jest-setup.js old mode 100755 new mode 100644 index c7546a3c26aeefcf775335f96875890412f3ba94..8ddb4e3dcc2ab8cec2a57e4b4696418e07e6ea10 --- 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