Skip to content

Commit

Permalink
feat!: remove @vitest/coverage-c8 package (#3614)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Jul 11, 2023
1 parent 0b893ae commit a90d64f
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 4,956 deletions.
55 changes: 0 additions & 55 deletions bench/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Expand Up @@ -37,7 +37,7 @@ export default withPwa(defineConfig({
['link', { rel: 'icon', href: '/favicon.ico', sizes: 'any' }],
['link', { rel: 'icon', href: '/logo.svg', type: 'image/svg+xml' }],
['meta', { name: 'author', content: `${teamMembers.map(c => c.name).join(', ')} and ${vitestName} contributors` }],
['meta', { name: 'keywords', content: 'vitest, vite, test, coverage, snapshot, react, vue, preact, svelte, solid, lit, ruby, cypress, puppeteer, jsdom, happy-dom, test-runner, jest, typescript, esm, tinypool, tinyspy, c8, node' }],
['meta', { name: 'keywords', content: 'vitest, vite, test, coverage, snapshot, react, vue, preact, svelte, solid, lit, ruby, cypress, puppeteer, jsdom, happy-dom, test-runner, jest, typescript, esm, tinypool, tinyspy, node' }],
['meta', { property: 'og:title', content: vitestName }],
['meta', { property: 'og:description', content: vitestDescription }],
['meta', { property: 'og:url', content: ogUrl }],
Expand Down
71 changes: 20 additions & 51 deletions docs/config/index.md
Expand Up @@ -667,10 +667,6 @@ Isolate environment for each test file. Does not work if you disable [`--threads

You can use [`v8`](https://v8.dev/blog/javascript-code-coverage), [`istanbul`](https://istanbul.js.org/) or [a custom coverage solution](/guide/coverage#custom-coverage-provider) for coverage collection.

::: info
The `c8` provider is being replaced by the `v8` provider. It will be deprecated in the next major version.
:::

You can provide coverage options to CLI with dot notation:

```sh
Expand All @@ -683,7 +679,7 @@ If you are using coverage options with dot notation, don't forget to specify `--

#### coverage.provider

- **Type:** `'c8' | 'v8' | 'istanbul' | 'custom'`
- **Type:** `'v8' | 'istanbul' | 'custom'`
- **Default:** `'v8'`
- **CLI:** `--coverage.provider=<provider>`

Expand All @@ -693,7 +689,7 @@ Use `provider` to select the tool for coverage collection.

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

Enables coverage collection. Can be overridden using `--coverage` CLI option.
Expand All @@ -702,7 +698,7 @@ Enables coverage collection. Can be overridden using `--coverage` CLI option.

- **Type:** `string[]`
- **Default:** `['**']`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.include=<path>`, `--coverage.include=<path1> --coverage.include=<path2>`

List of files included in coverage as glob patterns
Expand All @@ -711,7 +707,7 @@ List of files included in coverage as glob patterns

- **Type:** `string | string[]`
- **Default:** `['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte']`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.extension=<extension>`, `--coverage.extension=<extension1> --coverage.extension=<extension2>`

#### coverage.exclude
Expand All @@ -733,7 +729,7 @@ List of files included in coverage as glob patterns
'**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}',
]
```
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.exclude=<path>`, `--coverage.exclude=<path1> --coverage.exclude=<path2>`

List of files excluded from coverage as glob patterns.
Expand All @@ -742,7 +738,7 @@ List of files excluded from coverage as glob patterns.

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

Whether to include all files, including the untested ones into report.
Expand All @@ -751,7 +747,7 @@ Whether to include all files, including the untested ones into report.

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

Clean coverage results before running tests
Expand All @@ -760,7 +756,7 @@ Clean coverage results before running tests

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

Clean coverage report on watch rerun
Expand All @@ -769,7 +765,7 @@ Clean coverage report on watch rerun

- **Type:** `string`
- **Default:** `'./coverage'`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.reportsDirectory=<path>`

Directory to write coverage report to.
Expand All @@ -778,7 +774,7 @@ Directory to write coverage report to.

- **Type:** `string | string[] | [string, {}][]`
- **Default:** `['text', 'html', 'clover', 'json']`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.reporter=<reporter>`, `--coverage.reporter=<reporter1> --coverage.reporter=<reporter2>`

Coverage reporters to use. See [istanbul documentation](https://istanbul.js.org/docs/advanced/alternative-reporters/) for detailed list of all reporters. See [`@types/istanbul-reporter`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/276d95e4304b3670eaf6e8e5a7ea9e265a14e338/types/istanbul-reports/index.d.ts) for details about reporter specific options.
Expand All @@ -805,7 +801,7 @@ Since Vitest 0.31.0, you can check your coverage report in Vitest UI: check [Vit

- **Type:** `boolean`
- **Default:** `false` (since Vitest `0.34.0`)
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.reportOnFailure`, `--coverage.reportOnFailure=false`
- **Version:** Since Vitest 0.31.2

Expand All @@ -815,7 +811,7 @@ Generate coverage report even when tests fail.

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

Do not show files with 100% statement, branch, and function coverage.
Expand All @@ -824,7 +820,7 @@ Do not show files with 100% statement, branch, and function coverage.

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

Check thresholds per file.
Expand All @@ -834,7 +830,7 @@ See `lines`, `functions`, `branches` and `statements` for the actual thresholds.

- **Type:** `boolean`
- **Default:** `false`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.thresholdAutoUpdate=<boolean>`

Update threshold values `lines`, `functions`, `branches` and `statements` to configuration file when current coverage is above the configured thresholds.
Expand All @@ -843,7 +839,7 @@ This option helps to maintain thresholds when coverage is improved.
#### coverage.lines

- **Type:** `number`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.lines=<number>`

Threshold for lines.
Expand All @@ -852,7 +848,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
#### coverage.functions

- **Type:** `number`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.functions=<number>`

Threshold for functions.
Expand All @@ -861,7 +857,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
#### coverage.branches

- **Type:** `number`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.branches=<number>`

Threshold for branches.
Expand All @@ -870,44 +866,17 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-threshol
#### coverage.statements

- **Type:** `number`
- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.statements=<number>`

Threshold for statements.
See [istanbul documentation](https://github.com/istanbuljs/nyc#coverage-thresholds) for more information.

#### coverage.allowExternal

- **Type:** `boolean`
- **Default:** `false`
- **Available for providers:** `'c8'`
- **CLI:** `--coverage.allowExternal`, `--coverage.allowExternal=false`

Allow files from outside of your cwd.

#### coverage.excludeNodeModules

- **Type:** `boolean`
- **Default:** `true`
- **Available for providers:** `'c8'`
- **CLI:** `--coverage.excludeNodeModules`, `--coverage.excludeNodeModules=false`

Exclude coverage under `/node_modules/`.

#### coverage.src

- **Type:** `string[]`
- **Default:** `process.cwd()`
- **Available for providers:** `'c8'`
- **CLI:** `--coverage.src=<path>`

Specifies the directories that are used when `--all` is enabled.

#### coverage.100

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

Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`.
Expand Down Expand Up @@ -946,7 +915,7 @@ See [istanbul documentation](https://github.com/istanbuljs/nyc#ignoring-methods)
}
```

- **Available for providers:** `'c8' | 'v8' | 'istanbul'`
- **Available for providers:** `'v8' | '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
4 changes: 0 additions & 4 deletions docs/guide/coverage.md
Expand Up @@ -6,10 +6,6 @@ title: Coverage | Guide

Vitest supports Native code coverage via [`v8`](https://v8.dev/blog/javascript-code-coverage) and instrumented code coverage via [`istanbul`](https://istanbul.js.org/).

:::info
The `c8` provider is being replaced by the [`v8`](https://v8.dev/blog/javascript-code-coverage) provider. It will be deprecated in the next major version.
:::

## Coverage Providers

:::tip
Expand Down
2 changes: 1 addition & 1 deletion examples/react-testing-lib/package.json
Expand Up @@ -20,7 +20,7 @@
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"@vitejs/plugin-react": "latest",
"@vitest/coverage-c8": "^0.24.5",
"@vitest/coverage-v8": "latest",
"@vitest/ui": "latest",
"jsdom": "latest",
"typescript": "^4.8.4",
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -44,7 +44,6 @@
"@types/node": "^18.16.19",
"@types/ws": "^8.5.5",
"@vitest/browser": "workspace:*",
"@vitest/coverage-c8": "workspace:*",
"@vitest/coverage-istanbul": "workspace:*",
"@vitest/coverage-v8": "workspace:*",
"@vitest/ui": "workspace:*",
Expand Down
59 changes: 0 additions & 59 deletions packages/coverage-c8/package.json

This file was deleted.

0 comments on commit a90d64f

Please sign in to comment.