test: update jest config

pull/5784/head
tangjinzhou 2022-07-07 09:31:18 +08:00
parent 73bd25cbbe
commit b440215842
1 changed files with 12 additions and 5 deletions

View File

@ -9,18 +9,25 @@ const transformIgnorePatterns = [
]; ];
const testPathIgnorePatterns = ['/node_modules/', 'node']; const testPathIgnorePatterns = ['/node_modules/', 'node'];
function getTestRegex(libDir) {
if (libDir === 'dist') {
return 'demo\\.test\\.js$';
}
return '.*\\.test\\.(j|t)sx?$';
}
module.exports = { module.exports = {
verbose: true,
setupFiles: ['./tests/setup.js'], setupFiles: ['./tests/setup.js'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'vue', 'md', 'jpg'], moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'vue', 'md', 'jpg'],
modulePathIgnorePatterns: ['/_site/'], modulePathIgnorePatterns: ['/_site/'],
testPathIgnorePatterns: testPathIgnorePatterns, testPathIgnorePatterns: testPathIgnorePatterns,
transform: { transform: {
'^.+\\.(vue|md)$': '<rootDir>/node_modules/@vue/vue3-jest', '\\.(vue|md)$': '<rootDir>/node_modules/@vue/vue3-jest',
'^.+\\.(js|jsx)$': '<rootDir>/node_modules/babel-jest', '\\.(js|jsx)$': '<rootDir>/node_modules/babel-jest',
'^.+\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest', '\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest',
'^.+\\.svg$': '<rootDir>/node_modules/jest-transform-stub', '\\.svg$': '<rootDir>/node_modules/jest-transform-stub',
}, },
testRegex: libDir === 'dist' ? 'demo\\.test\\.js$' : '.*\\.test\\.js$', testRegex: getTestRegex(libDir),
moduleNameMapper: { moduleNameMapper: {
'/^@/(.*)$/': '<rootDir>/$1', '/^@/(.*)$/': '<rootDir>/$1',
'/ant-design-vue$/': '<rootDir>/components/index.ts', '/ant-design-vue$/': '<rootDir>/components/index.ts',