Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(coverage): add coverage['100'] to istanbul provider #4109

Merged
Merged
4 changes: 2 additions & 2 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,10 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol

- **Type:** `boolean`
- **Default:** `false`
- **Available for providers:** `'v8'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.100`, `--coverage.100=false`

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

#### coverage.ignoreClassMethods

Expand Down
4 changes: 4 additions & 0 deletions packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider implements Co
provider: 'istanbul',
reportsDirectory: resolve(ctx.config.root, config.reportsDirectory || coverageConfigDefaults.reportsDirectory),
reporter: this.resolveReporters(config.reporter || coverageConfigDefaults.reporter),
lines: config['100'] ? 100 : config.lines,
functions: config['100'] ? 100 : config.functions,
branches: config['100'] ? 100 : config.branches,
statements: config['100'] ? 100 : config.statements,
}

this.instrumenter = createInstrumenter({
Expand Down
16 changes: 8 additions & 8 deletions packages/vitest/src/types/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ export interface BaseCoverageOptions {
* @default false
*/
allowExternal?: boolean

/**
* Shortcut for `{ lines: 100, functions: 100, branches: 100, statements: 100 }`
*
* @default false
*/
100?: boolean
}

export interface CoverageIstanbulOptions extends BaseCoverageOptions {
Expand All @@ -235,14 +242,7 @@ export interface CoverageIstanbulOptions extends BaseCoverageOptions {
ignoreClassMethods?: string[]
}

export interface CoverageV8Options extends BaseCoverageOptions {
/**
* Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`
*
* @default false
*/
100?: boolean
}
export interface CoverageV8Options extends BaseCoverageOptions {}

export interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
/** Name of the module or path to a file to load the custom provider from */
Expand Down
13 changes: 2 additions & 11 deletions test/coverage-test/test/configuration-options.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test('provider options, generic', () => {
functions: [80, 95],
lines: [80, 95],
},
100: true,
})

assertType<Coverage>({
Expand All @@ -39,15 +40,11 @@ test('provider options, generic', () => {
watermarks: {
statements: [80, 95],
},
100: true,
})
})

test('provider specific options, v8', () => {
assertType<Coverage>({
provider: 'v8',
100: true,
})

assertType<Coverage>({
provider: 'v8',
// @ts-expect-error -- Istanbul-only option is not allowed
Expand All @@ -60,12 +57,6 @@ test('provider specific options, istanbul', () => {
provider: 'istanbul',
ignoreClassMethods: ['string'],
})

assertType<Coverage>({
provider: 'istanbul',
// @ts-expect-error -- V8-only option is not allowed
100: true,
})
})

test('provider specific options, custom', () => {
Expand Down
Loading