Skip to content

Commit

Permalink
fix(test): Jest with ES Modules of react-dnd (ant-design#17607)
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping authored Jul 13, 2019
1 parent e49707c commit 8798198
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 91 deletions.
10 changes: 9 additions & 1 deletion .jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ 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 = {
verbose: true,
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',
Expand Down
3 changes: 2 additions & 1 deletion .jest.node.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
150 changes: 61 additions & 89 deletions components/descriptions/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
<div>
<div
class="ant-descriptions"
class="ant-descriptions ant-descriptions-bordered"
>
<div
class="ant-descriptions-title"
Expand All @@ -293,128 +293,100 @@ exports[`renders ./components/descriptions/demo/responsive.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<th
class="ant-descriptions-item-label"
>
Product
</th>
<td
class="ant-descriptions-item"
class="ant-descriptions-item-content"
colspan="1"
>
<span
class="ant-descriptions-item-label"
>
Product
</span>
<span
class="ant-descriptions-item-content"
>
Cloud Database
</span>
Cloud Database
</td>
<th
class="ant-descriptions-item-label"
>
Billing
</th>
<td
class="ant-descriptions-item"
class="ant-descriptions-item-content"
colspan="1"
>
<span
class="ant-descriptions-item-label"
>
Billing
</span>
<span
class="ant-descriptions-item-content"
>
Prepaid
</span>
Prepaid
</td>
<th
class="ant-descriptions-item-label"
>
time
</th>
<td
class="ant-descriptions-item"
class="ant-descriptions-item-content"
colspan="1"
>
<span
class="ant-descriptions-item-label"
>
time
</span>
<span
class="ant-descriptions-item-content"
>
18:00:00
</span>
18:00:00
</td>
</tr>
<tr
class="ant-descriptions-row"
>
<th
class="ant-descriptions-item-label"
>
Amount
</th>
<td
class="ant-descriptions-item"
class="ant-descriptions-item-content"
colspan="1"
>
<span
class="ant-descriptions-item-label"
>
Amount
</span>
<span
class="ant-descriptions-item-content"
>
$80.00
</span>
$80.00
</td>
<th
class="ant-descriptions-item-label"
>
Discount
</th>
<td
class="ant-descriptions-item"
class="ant-descriptions-item-content"
colspan="1"
>
<span
class="ant-descriptions-item-label"
>
Discount
</span>
<span
class="ant-descriptions-item-content"
>
$20.00
</span>
$20.00
</td>
<th
class="ant-descriptions-item-label"
>
Official
</th>
<td
class="ant-descriptions-item"
class="ant-descriptions-item-content"
colspan="1"
>
<span
class="ant-descriptions-item-label"
>
Official
</span>
<span
class="ant-descriptions-item-content"
>
$60.00
</span>
$60.00
</td>
</tr>
<tr
class="ant-descriptions-row"
>
<th
class="ant-descriptions-item-label"
>
Config Info
</th>
<td
class="ant-descriptions-item"
colspan="3"
class="ant-descriptions-item-content"
colspan="5"
>
<span
class="ant-descriptions-item-label"
>
Config Info
</span>
<span
class="ant-descriptions-item-content"
>
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication_factor:3
<br />
Region: East China 1
</span>
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication_factor:3
<br />
Region: East China 1
</td>
</tr>
</tbody>
Expand Down

0 comments on commit 8798198

Please sign in to comment.