Skip to content

Commit a7e0993

Browse files
feat(coverage): add coverage['100'] to istanbul provider (#4109)
1 parent b75f91d commit a7e0993

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

docs/config/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,10 +1078,10 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
10781078

10791079
- **Type:** `boolean`
10801080
- **Default:** `false`
1081-
- **Available for providers:** `'v8'`
1081+
- **Available for providers:** `'v8' | 'istanbul'`
10821082
- **CLI:** `--coverage.100`, `--coverage.100=false`
10831083

1084-
Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`.
1084+
Shortcut for `--coverage.lines 100 --coverage.functions 100 --coverage.branches 100 --coverage.statements 100`.
10851085

10861086
#### coverage.ignoreClassMethods
10871087

packages/coverage-istanbul/src/provider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider implements Co
6161
provider: 'istanbul',
6262
reportsDirectory: resolve(ctx.config.root, config.reportsDirectory || coverageConfigDefaults.reportsDirectory),
6363
reporter: this.resolveReporters(config.reporter || coverageConfigDefaults.reporter),
64+
lines: config['100'] ? 100 : config.lines,
65+
functions: config['100'] ? 100 : config.functions,
66+
branches: config['100'] ? 100 : config.branches,
67+
statements: config['100'] ? 100 : config.statements,
6468
}
6569

6670
this.instrumenter = createInstrumenter({

packages/vitest/src/types/coverage.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ export interface BaseCoverageOptions {
224224
* @default false
225225
*/
226226
allowExternal?: boolean
227+
228+
/**
229+
* Shortcut for `{ lines: 100, functions: 100, branches: 100, statements: 100 }`
230+
*
231+
* @default false
232+
*/
233+
100?: boolean
227234
}
228235

229236
export interface CoverageIstanbulOptions extends BaseCoverageOptions {
@@ -235,14 +242,7 @@ export interface CoverageIstanbulOptions extends BaseCoverageOptions {
235242
ignoreClassMethods?: string[]
236243
}
237244

238-
export interface CoverageV8Options extends BaseCoverageOptions {
239-
/**
240-
* Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`
241-
*
242-
* @default false
243-
*/
244-
100?: boolean
245-
}
245+
export interface CoverageV8Options extends BaseCoverageOptions {}
246246

247247
export interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
248248
/** Name of the module or path to a file to load the custom provider from */

test/coverage-test/test/configuration-options.test-d.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ test('provider options, generic', () => {
3030
functions: [80, 95],
3131
lines: [80, 95],
3232
},
33+
100: true,
3334
})
3435

3536
assertType<Coverage>({
@@ -39,15 +40,11 @@ test('provider options, generic', () => {
3940
watermarks: {
4041
statements: [80, 95],
4142
},
43+
100: true,
4244
})
4345
})
4446

4547
test('provider specific options, v8', () => {
46-
assertType<Coverage>({
47-
provider: 'v8',
48-
100: true,
49-
})
50-
5148
assertType<Coverage>({
5249
provider: 'v8',
5350
// @ts-expect-error -- Istanbul-only option is not allowed
@@ -60,12 +57,6 @@ test('provider specific options, istanbul', () => {
6057
provider: 'istanbul',
6158
ignoreClassMethods: ['string'],
6259
})
63-
64-
assertType<Coverage>({
65-
provider: 'istanbul',
66-
// @ts-expect-error -- V8-only option is not allowed
67-
100: true,
68-
})
6960
})
7061

7162
test('provider specific options, custom', () => {

0 commit comments

Comments
 (0)