forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
39 lines (34 loc) · 995 Bytes
/
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
const preset = require("react-native/jest-preset");
function mapValues(obj, mapper) {
const mapped = {};
Object.keys(obj).forEach(key => {
mapped[key] = mapper(obj[key]);
});
return mapped;
}
function resolveName(packageName) {
switch (process.env.TEST_ENV) {
case "cjs":
return `<rootDir>/../${packageName}/cjs/${packageName}.js`;
case "umd":
return `<rootDir>/../${packageName}/umd/${packageName}.js`;
case "module":
default:
return `<rootDir>/../${packageName}/modules/index.js`;
}
}
module.exports = {
...preset,
testRunner: "jest-circus/runner",
restoreMocks: true,
moduleNameMapper: {
"^react-router$": resolveName("react-router"),
"^react-router-dom$": resolveName("react-router-dom"),
"^react-router-config": resolveName("react-router-config")
},
transform: mapValues(preset.transform, transformer =>
transformer === "babel-jest"
? ["babel-jest", { rootMode: "upward" }]
: transformer
)
};