-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.config.js
45 lines (40 loc) · 1.42 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
const { argv } = process;
/**
* Retrives the specified components only by eliminating:
* - The first two are `node` and `jest` URLs
* - Anything with `--` is an inline property such as `--watch` and `--detectOpenHandles`
*/
const specific = argv
.slice(2, argv.length)
.filter((value) => value.indexOf("--") === -1);
const collectCoverageFrom = [];
const testMatch = [];
function extractSpecifics(injectTo) {
return specific.map((item) => injectTo.replace("%inject%", item));
}
if (specific.length) {
collectCoverageFrom.push(...extractSpecifics("src/**/%inject%.(ts|js)"));
testMatch.push(...extractSpecifics("**/%inject%.test.(ts|js)"));
} else {
collectCoverageFrom.push("src/**/*.(ts|js)");
testMatch.push("**/*.test.(ts|js)");
}
collectCoverageFrom.push("!src/index.(ts|js)");
collectCoverageFrom.push("!src/**/index.(ts|js)");
module.exports = {
setupFilesAfterEnv: ["<rootDir>/setupTests.js"],
testEnvironment: "jsdom",
testMatch,
modulePaths: ["<rootDir>/node_modules"],
globals: { NODE_ENV: "test" },
verbose: true,
moduleFileExtensions: ["ts", "js", "json"],
transform: { "^.+\\.ts$": "ts-jest" },
transformIgnorePatterns: [],
testEnvironment: "node",
moduleNameMapper: { "aurelia-(.*)": "<rootDir>/node_modules/$1" },
collectCoverage: true,
collectCoverageFrom,
coverageDirectory: "./coverage",
coverageReporters: ["json", "lcov", "text"],
};