forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrunner-config-coverage_spec.ts
More file actions
120 lines (106 loc) · 3.07 KB
/
Copy pathrunner-config-coverage_spec.ts
File metadata and controls
120 lines (106 loc) · 3.07 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { execute } from '../../index';
import {
BASE_OPTIONS,
describeBuilder,
UNIT_TEST_BUILDER_INFO,
setupApplicationTarget,
} from '../setup';
describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
describe('Option: "runnerConfig" Coverage Merging', () => {
beforeEach(() => {
setupApplicationTarget(harness);
});
describe('Vitest Runner', () => {
it('should preserve thresholds from Vitest config when not overridden by CLI', async () => {
harness.writeFile(
'vitest-base.config.ts',
`
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
coverage: {
thresholds: {
branches: 100
}
}
}
});
`,
);
harness.useTarget('test', {
...BASE_OPTIONS,
runnerConfig: true,
coverage: true,
});
const { result } = await harness.executeOnce();
// Should fail because branches are not 100%
expect(result?.success).toBeFalse();
});
it('should override Vitest config thresholds with CLI thresholds', async () => {
harness.writeFile(
'vitest-base.config.ts',
`
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
coverage: {
thresholds: {
branches: 100
}
}
}
});
`,
);
harness.useTarget('test', {
...BASE_OPTIONS,
runnerConfig: true,
coverage: true,
coverageThresholds: {
branches: 0,
},
});
const { result } = await harness.executeOnce();
// Should pass because CLI overrides threshold to 0
expect(result?.success).toBeTrue();
});
it('should merge partial CLI thresholds with Vitest config thresholds', async () => {
harness.writeFile(
'vitest-base.config.ts',
`
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
coverage: {
thresholds: {
statements: 100,
branches: 100
}
}
}
});
`,
);
harness.useTarget('test', {
...BASE_OPTIONS,
runnerConfig: true,
coverage: true,
coverageThresholds: {
statements: 0,
// branches is undefined here, should remain 100 from config
},
});
const { result } = await harness.executeOnce();
// Should still fail because branches threshold (100) is not met
expect(result?.success).toBeFalse();
});
});
});
});