jest-setup.js 952 字节
Newer Older
W
wanganxp 已提交
1
// 自动化测试
2 3 4 5 6 7 8 9
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}__`
10 11 12 13 14 15 16
let environment = 'official'
if(hbuilderx_version.includes('dev')){
  environment = 'dev'
}else if(hbuilderx_version.includes('alpha')){
  environment = 'alpha'
}
const baseFolderName = `__image_snapshots__/base/${environment}/__${uniTestPlatformInfo}__`
17 18 19 20 21 22

expect.extend({
	toMatchImageSnapshot: configureToMatchImageSnapshot({
		customSnapshotIdentifier(args) {
			return args.currentTestName.replace(/\//g, '-').replace(' ', '-');
		},
23
		customSnapshotsDir: path.join(__dirname, baseFolderName),
24 25
		customDiffDir: path.join(__dirname, `${folderName}/`, 'diff'),
	}),
26
});