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