forked from dcos/dcos-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
68 lines (63 loc) · 2.05 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
const fs = require("fs");
/**
* List of root (test path) directories
*
* @description Jest will only search for tests and
* load manual mocks (e.g. `src/__mocks__/fs.js`) within these directories.
*
* @type {Array.<string>}
*/
const roots = ["./src", "./tests"];
/**
* List of package directories
*
* @description Packages (subdirectories) within these directories are
* going to be added as a "root" directory; this allows packages to roll
* their own "manual" mocks (e.g., `my-package/__mocks__/fs.js`),
* as Jest only loads them from root directories.
*
* @type {Array.<string>}
*/
const packages = ["plugins", "packages"];
// Add `npm_config_externalplugins` and strip trailing slash
// to make sure the paths are compatible.
if (process.env.npm_config_externalplugins) {
packages.push(process.env.npm_config_externalplugins.replace(/\/$/, ""));
}
// Traverse the subdirectories for every package directory and add the
// directories to the list root directories.
packages.forEach(function(packageDir) {
fs.readdirSync(packageDir).forEach(function(rootDir) {
const relativePath = packageDir + "/" + rootDir;
if (fs.statSync(relativePath).isDirectory()) {
roots.push("./" + relativePath);
}
});
});
module.exports = {
roots,
globals: {
__DEV__: true,
"ts-jest": {
useBabelrc: true
}
},
// TODO: split up transforms
transform: {
"^.+\\.tsx?$": "ts-jest",
".*": "./jest/preprocessor.js"
},
setupTestFrameworkScriptFile: "./jest/setupTestFramework.js",
setupFiles: ["./jest/setupEnv.js"],
testRegex: "/__tests__/.*\\-test\\.(es6|js|ts)$",
moduleFileExtensions: ["js", "json", "es6", "ts", "tsx"],
modulePathIgnorePatterns: ["/tmp/", "/node_modules/", "/.module-cache/"],
moduleNameMapper: {
"#SRC/([^\\.]*)$": "<rootDir>/src/$1",
"#PLUGINS/([^\\.]*)$": "<rootDir>/plugins/$1",
"#EXTERNAL_PLUGINS/([^\\.]*)$": "<rootDir>/../dcos-ui-plugins-private/$1"
},
timers: "fake",
coverageReporters: ["json", "lcov", "cobertura", "text"],
testPathIgnorePatterns: ["/tmp/", "/node_modules/"]
};