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): watermarks for c8 #3254

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#ignoring-methods)
}
```

- **Available for providers:** `'istanbul'`
- **Available for providers:** `'c8' | 'istanbul'`

Watermarks for statements, lines, branches and functions. See [istanbul documentation](https://github.com/istanbuljs/nyc#high-and-low-watermarks) for more information.

Expand Down
24 changes: 12 additions & 12 deletions packages/vitest/src/types/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ export interface BaseCoverageOptions {
*/
statements?: number

/**
* Watermarks for statements, lines, branches and functions.
*
* Default value is `[50,80]` for each property.
*/
watermarks?: {
statements?: [number, number]
functions?: [number, number]
branches?: [number, number]
lines?: [number, number]
}

/**
* Update threshold values automatically when current coverage is higher than earlier thresholds
*
Expand All @@ -202,18 +214,6 @@ export interface CoverageIstanbulOptions extends BaseCoverageOptions {
* @default []
*/
ignoreClassMethods?: string[]

/**
* Watermarks for statements, lines, branches and functions.
*
* Default value is `[50,80]` for each property.
*/
watermarks?: {
statements?: [number, number]
functions?: [number, number]
branches?: [number, number]
lines?: [number, number]
}
}

export interface CoverageC8Options extends BaseCoverageOptions {
Expand Down
13 changes: 7 additions & 6 deletions test/coverage-test/test/configuration-options.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ test('provider options, generic', () => {
provider: 'c8',
enabled: true,
include: ['string'],
watermarks: {
functions: [80, 95],
lines: [80, 95],
},
})

assertType<Coverage>({
provider: 'istanbul',
enabled: true,
include: ['string'],
watermarks: {
statements: [80, 95],
},
})
})

Expand All @@ -55,12 +62,6 @@ test('provider specific options, istanbul', () => {
assertType<Coverage>({
provider: 'istanbul',
ignoreClassMethods: ['string'],
watermarks: {
statements: [80, 95],
functions: [80, 95],
branches: [80, 95],
lines: [80, 95],
},
})

assertType<Coverage>({
Expand Down