Skip to content

Commit

Permalink
feat(coverage): watermarks for c8 (#3254)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Apr 27, 2023
1 parent efce3b4 commit 730af0b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
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

0 comments on commit 730af0b

Please sign in to comment.