-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathjest.base.js
executable file
·54 lines (51 loc) · 1.67 KB
/
jest.base.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
// Base jest configuration (https://jestjs.io/docs/en/configuration#coveragedirectory-string)
const path = require("path");
const pkg = require(path.resolve(process.env.PWD, "package.json"));
const isPlugin = !!pkg.slug;
const rootName = pkg.name.match(/^@(.*)\//)[1];
module.exports = {
roots: ["<rootDir>/test/jest/"].concat(isPlugin ? ["<rootDir>/src/public/ts"] : ["<rootDir>/lib"]),
testRegex: "(/test/jest/.*(\\.|/)(test|spec))\\.tsx$",
setupFilesAfterEnv: ["<rootDir>/../../common/jest.setupAfterEnv.js"],
transform: {
"^.+\\.tsx?$": [
"babel-jest",
{
babelrc: true,
babelrcRoots: [
".", // Keep the root as a root
// Also consider monorepo packages "root" and load their .babelrc files.
"../../packages/*",
"../../plugins/*"
]
}
]
},
transformIgnorePatterns: ["node_modules/(?!@" + rootName + ")"],
collectCoverage: false,
reporters: [
"default",
[
"jest-junit",
{
outputDirectory: "./test/junit",
outputName: "jest.xml"
}
]
],
coverageDirectory: "<rootDir>/coverage/jest",
collectCoverageFrom: [
"<rootDir>/lib/**/*.{tsx,ts}", // Packages
"<rootDir>/src/public/ts/**/*.{tsx,ts}", // Plugins
"!**/wp-api/*.{get,post,patch,put,delete,option,head}.{tsx,ts}"
],
coverageThreshold: {
global: {
lines: 80
}
},
snapshotSerializers: [],
moduleNameMapper: {
"\\.(css|less|scss)$": "identity-obj-proxy"
}
};