@abgov/nx-adsp 13.10.0 → 13.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/quality.d.ts +13 -3
- package/src/utils/quality.js +14 -4
- package/src/utils/quality.js.map +1 -1
- package/src/utils/quality.spec.ts +2 -0
package/package.json
CHANGED
package/src/utils/quality.d.ts
CHANGED
|
@@ -9,9 +9,19 @@ import { Tree } from '@nx/devkit';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function addEslintQualityRules(host: Tree, projectRoot: string, testFileGlobs: string[]): void;
|
|
11
11
|
/**
|
|
12
|
-
* Adds collectCoverage
|
|
13
|
-
* jest.config.cts. The threshold is
|
|
14
|
-
* added (passWithNoTests exits before
|
|
12
|
+
* Adds collectCoverage, a 60% line coverage threshold, and terminal-visible
|
|
13
|
+
* coverage reporters to the project's jest.config.cts. The threshold is
|
|
14
|
+
* inactive until the first test file is added (passWithNoTests exits before
|
|
15
|
+
* coverage is checked).
|
|
16
|
+
*
|
|
17
|
+
* @nx/jest's shared preset sets `coverageReporters: ['html']` — a report
|
|
18
|
+
* written to disk, with nothing printed to the terminal even when coverage
|
|
19
|
+
* runs. That's a real gap for a coding agent, whose main feedback loop *is*
|
|
20
|
+
* the terminal: a threshold failure alone only says the aggregate number
|
|
21
|
+
* dropped, not which files or lines are under it. `text` is set directly in
|
|
22
|
+
* this project's own jest.config.cts (overriding the preset's list for this
|
|
23
|
+
* project only, without touching the shared preset every other project
|
|
24
|
+
* inherits) so every `nx test` run prints the full per-file breakdown.
|
|
15
25
|
*/
|
|
16
26
|
export declare function addJestCoverageConfig(host: Tree, projectRoot: string): void;
|
|
17
27
|
/**
|
package/src/utils/quality.js
CHANGED
|
@@ -50,9 +50,19 @@ export default [
|
|
|
50
50
|
`);
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Adds collectCoverage
|
|
54
|
-
* jest.config.cts. The threshold is
|
|
55
|
-
* added (passWithNoTests exits before
|
|
53
|
+
* Adds collectCoverage, a 60% line coverage threshold, and terminal-visible
|
|
54
|
+
* coverage reporters to the project's jest.config.cts. The threshold is
|
|
55
|
+
* inactive until the first test file is added (passWithNoTests exits before
|
|
56
|
+
* coverage is checked).
|
|
57
|
+
*
|
|
58
|
+
* @nx/jest's shared preset sets `coverageReporters: ['html']` — a report
|
|
59
|
+
* written to disk, with nothing printed to the terminal even when coverage
|
|
60
|
+
* runs. That's a real gap for a coding agent, whose main feedback loop *is*
|
|
61
|
+
* the terminal: a threshold failure alone only says the aggregate number
|
|
62
|
+
* dropped, not which files or lines are under it. `text` is set directly in
|
|
63
|
+
* this project's own jest.config.cts (overriding the preset's list for this
|
|
64
|
+
* project only, without touching the shared preset every other project
|
|
65
|
+
* inherits) so every `nx test` run prints the full per-file breakdown.
|
|
56
66
|
*/
|
|
57
67
|
function addJestCoverageConfig(host, projectRoot) {
|
|
58
68
|
const jestPath = `${projectRoot}/jest.config.cts`;
|
|
@@ -63,7 +73,7 @@ function addJestCoverageConfig(host, projectRoot) {
|
|
|
63
73
|
// it with one before the inserted properties. @nx/jest may leave
|
|
64
74
|
// coverageDirectory as the last property (no trailing comma), so appending
|
|
65
75
|
// properties after it verbatim would produce an invalid object literal.
|
|
66
|
-
const modified = existing.replace(/([ \t]*coverageDirectory:[^\n]*?),?\n/, `$1,\n collectCoverage: true,\n coverageThreshold: {\n global: {\n lines: 60,\n },\n },\n`);
|
|
76
|
+
const modified = existing.replace(/([ \t]*coverageDirectory:[^\n]*?),?\n/, `$1,\n collectCoverage: true,\n coverageReporters: ['html', 'text'],\n coverageThreshold: {\n global: {\n lines: 60,\n },\n },\n`);
|
|
67
77
|
if (modified !== existing) {
|
|
68
78
|
host.write(jestPath, modified);
|
|
69
79
|
}
|
package/src/utils/quality.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quality.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/quality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I,MAAM,CAAC;YAC1D,uCAAY,QAAQ,KAAE,UAAU,IAAG;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,IAAA,kBAAS,EAAC,IAAI,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,CAAC,GAAG,CACT,gEAAgE;QAC9D,iFAAiF;QACjF,+EAA+E,CAClF,CAAC;AACJ,CAAC"}
|
|
@@ -38,11 +38,13 @@ describe('addJestCoverageConfig', () => {
|
|
|
38
38
|
|
|
39
39
|
expect(out).toContain("coverageDirectory: 'test-output/jest/coverage',");
|
|
40
40
|
expect(out).toContain('collectCoverage: true,');
|
|
41
|
+
expect(out).toContain("coverageReporters: ['html', 'text'],");
|
|
41
42
|
expect(out).toContain('lines: 60,');
|
|
42
43
|
expect(out).not.toContain(',,');
|
|
43
44
|
// The result must be a valid object literal.
|
|
44
45
|
const cfg = evalConfigObject(out);
|
|
45
46
|
expect(cfg.collectCoverage).toBe(true);
|
|
47
|
+
expect(cfg.coverageReporters).toEqual(['html', 'text']);
|
|
46
48
|
expect(
|
|
47
49
|
(cfg.coverageThreshold as { global: { lines: number } }).global.lines,
|
|
48
50
|
).toBe(60);
|