diff --git a/.jest.js b/.jest.js index cc38788c90..be003ba592 100644 --- a/.jest.js +++ b/.jest.js @@ -2,7 +2,7 @@ const libDir = process.env.LIB_DIR; const transformIgnorePatterns = [ '/dist/', - 'node_modules/(?!(_react-dnd|react-dnd|_dnd-core|dnd-core))[^/]+?/(?!(es|node_modules)/)', // Ignore modules without es dir + 'node_modules/[^/]+?/(?!(es|node_modules)/)', // Ignore modules without es dir ]; module.exports = { @@ -10,6 +10,14 @@ module.exports = { setupFiles: ['./tests/setup.js'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'md'], modulePathIgnorePatterns: ['/_site/'], + moduleNameMapper: { + '^dnd-core$': 'dnd-core/dist/cjs', + '^react-dnd$': 'react-dnd/dist/cjs', + '^react-dnd-html5-backend$': 'react-dnd-html5-backend/dist/cjs', + '^react-dnd-touch-backend$': 'react-dnd-touch-backend/dist/cjs', + '^react-dnd-test-backend$': 'react-dnd-test-backend/dist/cjs', + '^react-dnd-test-utils$': 'react-dnd-test-utils/dist/cjs', + }, testPathIgnorePatterns: ['/node_modules/', 'dekko', 'node'], transform: { '\\.tsx?$': './node_modules/antd-tools/lib/jest/codePreprocessor', diff --git a/.jest.node.js b/.jest.node.js index 64dd63e8df..55e3cef03f 100644 --- a/.jest.node.js +++ b/.jest.node.js @@ -1,9 +1,10 @@ -const { transformIgnorePatterns } = require('./.jest'); +const { moduleNameMapper, transformIgnorePatterns } = require('./.jest'); // jest config for server render environment module.exports = { setupFiles: ['./tests/setup.js'], moduleFileExtensions: ['ts', 'tsx', 'js', 'md'], + moduleNameMapper, transform: { '\\.tsx?$': './node_modules/antd-tools/lib/jest/codePreprocessor', '\\.js$': './node_modules/antd-tools/lib/jest/codePreprocessor', diff --git a/components/descriptions/__tests__/__snapshots__/demo.test.js.snap b/components/descriptions/__tests__/__snapshots__/demo.test.js.snap index 7ed955a48f..b2edc17b4c 100644 --- a/components/descriptions/__tests__/__snapshots__/demo.test.js.snap +++ b/components/descriptions/__tests__/__snapshots__/demo.test.js.snap @@ -278,7 +278,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = ` exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `