-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjest.config.js
More file actions
70 lines (68 loc) · 2.26 KB
/
Copy pathjest.config.js
File metadata and controls
70 lines (68 loc) · 2.26 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
/** @type {import('jest').Config} */
module.exports = {
clearMocks: true,
moduleFileExtensions: ["js", "ts"],
testEnvironment: "node",
testMatch: ["**/__tests__/**/*.test.ts"],
transform: {
"^.+\\.ts$": [
"ts-jest",
{
tsconfig: "tsconfig.test.json",
},
],
},
collectCoverageFrom: [
"src/**/*.ts",
"!src/**/*.d.ts",
"!src/index.ts",
],
coverageReporters: ["text", "text-summary", "lcov", "html", "cobertura"],
// Default reporter (console output) + JUnit XML for CI artifacts. The
// jest-junit reporter is configured via `reporterOptions` below; the
// file lands at coverage/junit.xml so it ships alongside the coverage
// reports in a single artifact upload.
reporters: [
"default",
[
"jest-junit",
{
outputDirectory: "coverage",
outputName: "junit.xml",
suiteNameTemplate: "{filepath}",
classNameTemplate: "{classname}",
titleTemplate: "{title}",
ancestorSeparator: " › ",
addFileAttribute: "true",
includeConsoleOutput: "false",
},
],
],
coverageThreshold: {
global: {
branches: 75,
// Slightly relaxed from a previous 93% target after the migration
// away from a hand-rolled axios client to `@azure-rest/ai-translation-text`.
// ts-jest's istanbul instrumentation attributes a handful of phantom
// "anonymous functions" to import/comment lines in the rewritten
// `src/api/translation-api.ts`; those are source-map artifacts, not
// genuinely untested code (every real branch is covered by the tests
// in `__tests__/api.test.ts`). 90% gives us enough headroom that we
// don't trip on instrumentation noise while still failing fast if a
// real function ever lands without a test.
functions: 90,
lines: 85,
statements: 85,
},
},
verbose: true,
};
const processStdoutWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = (str, encoding, cb) => {
// Core library will directly call process.stdout.write for runner commands.
// We don't want :: commands to be executed by the runner during tests.
if (typeof str === "string" && !str.match(/^::/)) {
return processStdoutWrite(str, encoding, cb);
}
return true;
};