From 879819811320ab176eb007660f365262a4b90592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AF=B8=E5=B2=B3?= Date: Sat, 13 Jul 2019 10:29:47 +0800 Subject: [PATCH] fix(test): Jest with ES Modules of react-dnd (#17607) --- .jest.js | 10 +- .jest.node.js | 3 +- .../__tests__/__snapshots__/demo.test.js.snap | 150 +++++++----------- 3 files changed, 72 insertions(+), 91 deletions(-) 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`] = `
+ + Product + - - Product - - - Cloud Database - + Cloud Database + + Billing + - - Billing - - - Prepaid - + Prepaid + + time + - - time - - - 18:00:00 - + 18:00:00 + + Amount + - - Amount - - - $80.00 - + $80.00 + + Discount + - - Discount - - - $20.00 - + $20.00 + + Official + - - Official - - - $60.00 - + $60.00 + + Config Info + - - Config Info - - - Data disk type: MongoDB -
- Database version: 3.4 -
- Package: dds.mongo.mid -
- Storage space: 10 GB -
- Replication_factor:3 -
- Region: East China 1 -
+ Data disk type: MongoDB +
+ Database version: 3.4 +
+ Package: dds.mongo.mid +
+ Storage space: 10 GB +
+ Replication_factor:3 +
+ Region: East China 1