Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
104 lines (100 loc) · 3.54 KB
/
Copy pathjest.config.js
File metadata and controls
104 lines (100 loc) · 3.54 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"use strict";
// coverage instrumentation slows every build; test/helpers/testTimeout.js
// reads this as a global, not from the environment the builds can expose
const coverage = process.argv.some((arg) =>
/^--(coverage|collectCoverage|collect-coverage)(=true)?$/.test(arg)
);
/** @type {import("jest").Config} */
const config = {
testTimeout: coverage ? 90000 : 30000,
globals: { __WEBPACK_TEST_COVERAGE__: coverage },
prettierPath: require.resolve("prettier-2"),
forceExit: true,
globalSetup: "<rootDir>/test/harness/globalSetup.js",
globalTeardown: "<rootDir>/test/harness/globalTeardown.js",
setupFiles: [
"<rootDir>/test/harness/runtimes/bun-sandbox-setup.js",
"<rootDir>/test/harness/runtimes/deno-worker-setup.js"
],
setupFilesAfterEnv: ["<rootDir>/test/harness/setupTestFramework.js"],
testMatch: [
"<rootDir>/test/*.test.js",
"<rootDir>/test/*.basictest.js",
"<rootDir>/test/*.longtest.js",
"<rootDir>/test/unitCases/**/*.unittest.js",
"<rootDir>/test/specCases/*.spectest.js"
],
watchPathIgnorePatterns: [
"<rootDir>/.git",
"<rootDir>/node_modules",
"<rootDir>/test/external/wpt",
"<rootDir>/test/external/swc",
"<rootDir>/test/external/oxc",
"<rootDir>/test/js",
"<rootDir>/test/fixtures/temp-cache-fixture",
"<rootDir>/test/fixtures/temp-",
"<rootDir>/assembly",
"<rootDir>/tooling",
"<rootDir>/examples/*/dist",
"<rootDir>/coverage",
"<rootDir>/.eslintcache"
],
modulePathIgnorePatterns: [
"<rootDir>/.git",
"<rootDir>/test/external/wpt",
"<rootDir>/test/external/swc",
"<rootDir>/test/external/oxc",
"<rootDir>/node_modules/webpack/node_modules",
"<rootDir>/test/js",
"<rootDir>/test/fixtures/temp-cache-fixture",
"<rootDir>/test/fixtures/temp-",
"<rootDir>/examples/*/dist",
"<rootDir>/coverage",
"<rootDir>/.eslintcache"
],
transformIgnorePatterns: ["<rootDir>"],
coverageDirectory: "<rootDir>/coverage",
coveragePathIgnorePatterns: [
"\\.runtime\\.js$",
// Serialized to the minimizer's worker pool as source (like runtime code):
// coverage instrumentation would inject counters the worker can't resolve.
"[\\\\/]lib[\\\\/](?:css[\\\\/]cssMinify|html[\\\\/](?:htmlMinify|xmlMinify)|javascript[\\\\/]jsMinify|json[\\\\/]jsonMinify)\\.js$",
"<rootDir>/test",
"<rootDir>/schemas",
"<rootDir>/examples",
"<rootDir>/node_modules"
],
testEnvironment: "./test/harness/patch-node-env.js",
snapshotResolver: "./test/harness/snapshot/resolver.js",
coverageReporters: ["json"],
snapshotFormat: {
escapeString: true,
printBasicPrototype: true
}
};
// `--parts=<n>` runs every matched file in n parallel workers at once, each
// told its part through `test/helpers/testParts.js`; setup runs once.
// `--parts=auto` takes one part per core the machine has.
const partsArg = process.argv.find((arg) => arg.startsWith("--parts="));
const partsValue = partsArg ? partsArg.slice("--parts=".length) : "1";
const parts =
partsValue === "auto" ? require("os").cpus().length : Number(partsValue);
// Jest reads these only from the top level and warns when a project sets them.
const { forceExit, coverageReporters, ...projectConfig } = config;
module.exports =
parts > 1
? {
// global options (coverage, forceExit) are read from the top level
...config,
projects: Array.from({ length: parts }, (_, index) => ({
...projectConfig,
rootDir: __dirname,
displayName: `part ${index + 1}/${parts}`,
globals: { ...config.globals, __TEST_PART__: [index + 1, parts] },
...(index > 0 && {
globalSetup: undefined,
globalTeardown: undefined
})
}))
}
: config;