2022-11-09 12:28:04 +08:00
|
|
|
const compileModules = [
|
|
|
|
'array-move',
|
|
|
|
'react-dnd',
|
|
|
|
'react-dnd-html5-backend',
|
|
|
|
'@react-dnd',
|
|
|
|
'dnd-core',
|
|
|
|
'tween-one',
|
|
|
|
'@babel',
|
|
|
|
'@ant-design',
|
|
|
|
];
|
|
|
|
|
|
|
|
const ignoreList = [];
|
|
|
|
|
|
|
|
// cnpm use `_` as prefix
|
2022-11-13 14:33:07 +08:00
|
|
|
['', '_'].forEach((prefix) => {
|
|
|
|
compileModules.forEach((module) => {
|
2022-11-09 12:28:04 +08:00
|
|
|
ignoreList.push(`${prefix}${module}`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-30 15:29:28 +08:00
|
|
|
const transformIgnorePatterns = [
|
2020-03-29 14:07:42 +08:00
|
|
|
// Ignore modules without es dir.
|
|
|
|
// Update: @babel/runtime should also be transformed
|
2022-11-09 12:28:04 +08:00
|
|
|
`/node_modules/(?!${ignoreList.join('|')})[^/]+?/(?!(es)/)`,
|
2017-06-30 15:29:28 +08:00
|
|
|
];
|
|
|
|
|
2020-04-13 13:36:23 +08:00
|
|
|
function getTestRegex(libDir) {
|
|
|
|
if (libDir === 'dist') {
|
2022-10-08 16:17:20 +08:00
|
|
|
return 'demo\\.test\\.(j|t)s$';
|
2020-04-13 13:36:23 +08:00
|
|
|
}
|
|
|
|
return '.*\\.test\\.(j|t)sx?$';
|
|
|
|
}
|
|
|
|
|
2017-06-30 15:29:28 +08:00
|
|
|
module.exports = {
|
2018-08-02 20:25:14 +08:00
|
|
|
verbose: true,
|
2021-06-01 10:11:24 +08:00
|
|
|
testEnvironment: 'jsdom',
|
2022-12-08 18:06:36 +08:00
|
|
|
setupFiles: ['./tests/setup.js', 'jest-canvas-mock'],
|
2020-04-06 12:05:38 +08:00
|
|
|
setupFilesAfterEnv: ['./tests/setupAfterEnv.ts'],
|
2018-12-16 11:26:36 +08:00
|
|
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'md'],
|
|
|
|
modulePathIgnorePatterns: ['/_site/'],
|
2019-07-13 10:29:47 +08:00
|
|
|
moduleNameMapper: {
|
2022-05-09 23:17:26 +08:00
|
|
|
'/\\.(css|less)$/': 'identity-obj-proxy',
|
2022-11-09 12:28:04 +08:00
|
|
|
'^antd$': '<rootDir>/components/index',
|
|
|
|
'^antd/es/(.*)$': '<rootDir>/components/$1',
|
2019-07-13 10:29:47 +08:00
|
|
|
},
|
2020-10-23 18:50:46 +08:00
|
|
|
testPathIgnorePatterns: ['/node_modules/', 'dekko', 'node', 'image.test.js', 'image.test.ts'],
|
2017-06-30 15:29:28 +08:00
|
|
|
transform: {
|
2019-08-01 15:28:16 +08:00
|
|
|
'\\.tsx?$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
2021-02-23 13:08:31 +08:00
|
|
|
'\\.(m?)js$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
2019-08-01 15:28:16 +08:00
|
|
|
'\\.md$': './node_modules/@ant-design/tools/lib/jest/demoPreprocessor',
|
|
|
|
'\\.(jpg|png|gif|svg)$': './node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
2017-06-30 15:29:28 +08:00
|
|
|
},
|
2020-04-13 13:36:23 +08:00
|
|
|
testRegex: getTestRegex(process.env.LIB_DIR),
|
2017-06-30 15:29:28 +08:00
|
|
|
collectCoverageFrom: [
|
|
|
|
'components/**/*.{ts,tsx}',
|
|
|
|
'!components/*/style/index.tsx',
|
|
|
|
'!components/style/index.tsx',
|
|
|
|
'!components/*/locale/index.tsx',
|
2019-12-09 14:38:36 +08:00
|
|
|
'!components/*/__tests__/type.test.tsx',
|
2018-01-29 11:27:53 +08:00
|
|
|
'!components/**/*/interface.{ts,tsx}',
|
2020-10-23 18:50:46 +08:00
|
|
|
'!components/*/__tests__/image.test.{ts,tsx}',
|
2022-09-09 15:51:35 +08:00
|
|
|
'!components/__tests__/node.test.tsx',
|
2022-11-09 12:28:04 +08:00
|
|
|
'!components/*/demo/*.tsx',
|
2017-06-30 15:29:28 +08:00
|
|
|
],
|
|
|
|
transformIgnorePatterns,
|
2017-11-17 14:38:54 +08:00
|
|
|
globals: {
|
|
|
|
'ts-jest': {
|
2018-12-16 11:26:36 +08:00
|
|
|
tsConfig: './tsconfig.test.json',
|
2018-08-10 13:49:06 +08:00
|
|
|
},
|
2017-11-17 14:38:54 +08:00
|
|
|
},
|
2022-05-09 23:17:26 +08:00
|
|
|
testEnvironmentOptions: {
|
|
|
|
url: 'http://localhost',
|
|
|
|
},
|
2022-11-13 14:33:07 +08:00
|
|
|
// bail: true,
|
2017-06-30 15:29:28 +08:00
|
|
|
};
|