mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
1fc374495f
* chore: init test * test: rootClassName inject * test: part of test * chore: patch qrcode rootCls * chore: part rootClassName * chore: part rootClassName * test: more test * test: more test * test: more test * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * test: more test * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: part rootClassName * chore: fix lint * chore: fix lint * chore: ignore part of lint * test: update snapshot * test: fix test case * chore: fix node test * chore: adjust render logic * fix: test * test: update snapshot * test: update * refactor * chore: fix require module logic
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
const compileModules = [
|
|
'array-move',
|
|
'react-dnd',
|
|
'react-dnd-html5-backend',
|
|
'@react-dnd',
|
|
'dnd-core',
|
|
'react-sticky-box',
|
|
'tween-one',
|
|
'@babel',
|
|
'@ant-design',
|
|
];
|
|
|
|
const ignoreList = [];
|
|
|
|
// cnpm use `_` as prefix
|
|
['', '_'].forEach((prefix) => {
|
|
compileModules.forEach((module) => {
|
|
ignoreList.push(`${prefix}${module}`);
|
|
});
|
|
});
|
|
|
|
const transformIgnorePatterns = [
|
|
// Ignore modules without es dir.
|
|
// Update: @babel/runtime should also be transformed
|
|
`/node_modules/(?!${ignoreList.join('|')})[^/]+?/(?!(es)/)`,
|
|
];
|
|
|
|
function getTestRegex(libDir) {
|
|
if (['dist', 'lib', 'es'].includes(libDir)) {
|
|
return 'demo\\.test\\.(j|t)sx?$';
|
|
}
|
|
return '.*\\.test\\.(j|t)sx?$';
|
|
}
|
|
|
|
module.exports = {
|
|
verbose: true,
|
|
testEnvironment: 'jsdom',
|
|
setupFiles: ['./tests/setup.js', 'jest-canvas-mock'],
|
|
setupFilesAfterEnv: ['./tests/setupAfterEnv.ts'],
|
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'md'],
|
|
modulePathIgnorePatterns: ['/_site/'],
|
|
moduleNameMapper: {
|
|
'/\\.(css|less)$/': 'identity-obj-proxy',
|
|
'^antd$': '<rootDir>/components/index',
|
|
'^antd/es/(.*)$': '<rootDir>/components/$1',
|
|
},
|
|
testPathIgnorePatterns: ['/node_modules/', 'dekko', 'node', 'image.test.js', 'image.test.ts'],
|
|
transform: {
|
|
'\\.tsx?$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
|
'\\.(m?)js$': './node_modules/@ant-design/tools/lib/jest/codePreprocessor',
|
|
'\\.md$': './node_modules/@ant-design/tools/lib/jest/demoPreprocessor',
|
|
'\\.(jpg|png|gif|svg)$': './node_modules/@ant-design/tools/lib/jest/imagePreprocessor',
|
|
},
|
|
testRegex: getTestRegex(process.env.LIB_DIR),
|
|
collectCoverageFrom: [
|
|
'components/**/*.{ts,tsx}',
|
|
'!components/*/style/index.tsx',
|
|
'!components/style/index.tsx',
|
|
'!components/*/locale/index.tsx',
|
|
'!components/*/__tests__/type.test.tsx',
|
|
'!components/**/*/interface.{ts,tsx}',
|
|
'!components/*/__tests__/image.test.{ts,tsx}',
|
|
'!components/__tests__/node.test.tsx',
|
|
'!components/*/demo/*.tsx',
|
|
],
|
|
transformIgnorePatterns,
|
|
globals: {
|
|
'ts-jest': {
|
|
tsConfig: './tsconfig.test.json',
|
|
},
|
|
},
|
|
testEnvironmentOptions: {
|
|
url: 'http://localhost',
|
|
},
|
|
// bail: true,
|
|
maxWorkers: '50%',
|
|
};
|