-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjest.config.js
73 lines (69 loc) · 1.88 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const path = require('path'); // eslint-disable-line @typescript-eslint/no-var-requires
// D3, since version 7, is distributed only as ES modules,
// which presents a problem for Jest, as it is configured for our project (uses commonjs modules)
// The solution for this problem is taken from the list of possible solutions in D3's Changelog
// (https://github.com/recharts/recharts/commit/e62d0cf8aaecdc135615c40ae6d95288026d97d5)
const d3Pkgs = [
'd3',
'd3-array',
'd3-axis',
'd3-brush',
'd3-chord',
'd3-color',
'd3-contour',
'd3-delaunay',
'd3-dispatch',
'd3-drag',
'd3-dsv',
'd3-ease',
'd3-fetch',
'd3-force',
'd3-format',
'd3-geo',
'd3-hierarchy',
'd3-interpolate',
'd3-path',
'd3-polygon',
'd3-quadtree',
'd3-random',
'd3-scale',
'd3-scale-chromatic',
'd3-selection',
'd3-shape',
'd3-time',
'd3-time-format',
'd3-timer',
'd3-transition',
'd3-zoom',
];
const d3ModuleNameMapper = d3Pkgs.reduce((acc, pkg) => {
acc[`^${pkg}$`] = path.join(require.resolve(pkg), `../../dist/${pkg}.min.js`);
return acc;
}, {});
module.exports = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'\\.svg': '<rootDir>/tests/svgrMock.js',
'^config$': '<rootDir>/config.ts',
'(tests/.*)$$': '<rootDir>/$1',
'(src/.*)$': '<rootDir>/$1',
'(static/.*)$': '<rootDir>/$1',
'(static/browser/.*)$': '<rootDir>/$1.stub.js',
'\\.(css)$': 'identity-obj-proxy',
...d3ModuleNameMapper
},
roots: ['<rootDir>/src'],
setupFiles: ['<rootDir>/tests/setup-jest.js'],
setupFilesAfterEnv: [
'<rootDir>/tests/setup-rtl.ts'
],
testEnvironment: './tests/fixed-jsdom-environment',
testEnvironmentOptions: {
customExportConditions: [''], // this specific setting is to allow the use of msw/node
},
transform: {
'.+\\.tsx?$': 'babel-jest',
'.+\\.(css|png|jpg|svg|gif|eot|ttf|otf|woff|woff2)$':
'jest-transform-stub'
}
};