2018-05-13 23:11:51 +08:00
|
|
|
const libDir = process.env.LIB_DIR;
|
|
|
|
|
|
|
|
const transformIgnorePatterns = [
|
2019-09-28 19:20:26 +08:00
|
|
|
'/dist/',
|
2020-09-07 18:28:03 +08:00
|
|
|
// Ignore modules without es dir.
|
|
|
|
// Update: @babel/runtime should also be transformed
|
|
|
|
'node_modules/(?!.*(@babel|lodash-es))[^/]+?/(?!(es|node_modules)/)',
|
2018-05-13 23:11:51 +08:00
|
|
|
];
|
2020-09-23 17:32:53 +08:00
|
|
|
const testPathIgnorePatterns = ['/node_modules/', 'node'];
|
|
|
|
if (process.env.WORKFLOW === 'true') {
|
|
|
|
testPathIgnorePatterns.push('demo\\.test*');
|
|
|
|
}
|
2018-05-13 23:11:51 +08:00
|
|
|
module.exports = {
|
2018-07-27 18:31:34 +08:00
|
|
|
testURL: 'http://localhost/',
|
2018-08-04 17:52:11 +08:00
|
|
|
setupFiles: ['./tests/setup.js'],
|
2019-09-28 19:20:26 +08:00
|
|
|
moduleFileExtensions: ['js', 'jsx', 'json', 'vue', 'md', 'jpg'],
|
2018-08-04 17:52:11 +08:00
|
|
|
modulePathIgnorePatterns: ['/_site/'],
|
2020-09-23 17:32:53 +08:00
|
|
|
testPathIgnorePatterns: testPathIgnorePatterns,
|
2018-05-13 23:11:51 +08:00
|
|
|
transform: {
|
2020-07-25 14:34:22 +08:00
|
|
|
'^.+\\.(vue|md)$': '<rootDir>/node_modules/vue-jest',
|
2019-09-28 19:20:26 +08:00
|
|
|
'^.+\\.(js|jsx)$': '<rootDir>/node_modules/babel-jest',
|
|
|
|
'^.+\\.svg$': '<rootDir>/node_modules/jest-transform-stub',
|
2018-05-13 23:11:51 +08:00
|
|
|
},
|
2019-09-28 19:20:26 +08:00
|
|
|
testRegex: libDir === 'dist' ? 'demo\\.test\\.js$' : '.*\\.test\\.js$',
|
2018-05-13 23:11:51 +08:00
|
|
|
moduleNameMapper: {
|
2019-09-28 19:20:26 +08:00
|
|
|
'^@/(.*)$': '<rootDir>/$1',
|
2020-03-15 13:12:47 +08:00
|
|
|
'ant-design-vue$': '<rootDir>/components/index.js',
|
|
|
|
'ant-design-vue/es': '<rootDir>/components',
|
2018-05-13 23:11:51 +08:00
|
|
|
},
|
2019-09-28 19:20:26 +08:00
|
|
|
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
|
2018-05-13 23:11:51 +08:00
|
|
|
collectCoverage: process.env.COVERAGE === 'true',
|
|
|
|
collectCoverageFrom: [
|
2019-09-28 19:20:26 +08:00
|
|
|
'components/**/*.{js,jsx,vue}',
|
2018-05-13 23:11:51 +08:00
|
|
|
'!components/*/style/index.{js,jsx}',
|
2018-05-14 10:20:05 +08:00
|
|
|
'!components/style/*.{js,jsx}',
|
|
|
|
'!components/*/locale/*.{js,jsx}',
|
2018-05-13 23:11:51 +08:00
|
|
|
'!components/*/__tests__/**/type.{js,jsx}',
|
2018-05-14 10:20:05 +08:00
|
|
|
'!components/vc-*/**/*',
|
|
|
|
'!components/*/demo/**/*',
|
|
|
|
'!components/_util/**/*',
|
|
|
|
'!components/align/**/*',
|
|
|
|
'!components/trigger/**/*',
|
|
|
|
'!components/style.js',
|
2019-09-28 19:20:26 +08:00
|
|
|
'!**/node_modules/**',
|
2018-05-13 23:11:51 +08:00
|
|
|
],
|
2020-07-25 15:46:49 +08:00
|
|
|
testEnvironment: 'jest-environment-jsdom-fifteen',
|
2019-09-28 19:20:26 +08:00
|
|
|
transformIgnorePatterns,
|
2018-05-13 23:11:51 +08:00
|
|
|
};
|