Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 86a973e

Browse files
committed
feat(package.json): configure jest
1 parent 7df7926 commit 86a973e

File tree

9 files changed

+3495
-67
lines changed

9 files changed

+3495
-67
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"env": {
33
"browser": true,
44
"es6": true,
5+
"jest": true,
56
"node": true
67
},
78

babel.config.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = function(api) {
2-
api.cache.using(() => process.env.NODE_ENV);
2+
const isTest = String(api.env()) === "test";
33

44
const plugins = [
55
"react-hot-loader/babel",
@@ -26,15 +26,18 @@ module.exports = function(api) {
2626
"@babel/plugin-syntax-dynamic-import",
2727
"@babel/plugin-syntax-import-meta",
2828
["@babel/plugin-proposal-class-properties", { loose: false }],
29-
"@babel/plugin-proposal-json-strings"
30-
];
29+
"@babel/plugin-proposal-json-strings",
30+
31+
// jest
32+
isTest ? "babel-plugin-dynamic-import-node" : null
33+
].filter(Boolean);
3134

3235
const presets = [
3336
[
3437
"@babel/preset-env",
3538
{
36-
debug: true,
37-
modules: false,
39+
debug: false,
40+
modules: isTest ? "commonjs" : false,
3841
useBuiltIns: "usage"
3942
}
4043
],

jest.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
collectCoverageFrom: ["**/src/**/*.js"],
3+
coverageThreshold: {
4+
global: {
5+
statements: 10,
6+
branches: 10,
7+
functions: 10,
8+
lines: 10
9+
}
10+
},
11+
displayName: "client",
12+
moduleNameMapper: {
13+
"\\.css": "identity-obj-proxy",
14+
"\\.svg$": "<rootDir>/test/svg-file-mock.js"
15+
},
16+
modulePaths: ["<rootDir>/src", "<rootDir>/test"],
17+
setupTestFrameworkScriptFile: require.resolve(
18+
"./test/setup-test-framework.js"
19+
),
20+
testPathIgnorePatterns: ["/node_modules/"]
21+
};

0 commit comments

Comments
 (0)