···16281628}
16291629```
1630163016311631-#### coverage.ignoreEmptyLines
16321632-16331633-- **Type:** `boolean`
16341634-- **Default:** `true` (`false` in v1)
16351635-- **Available for providers:** `'v8'`
16361636-- **CLI:** `--coverage.ignoreEmptyLines=<boolean>`
16371637-16381638-Ignore empty lines, comments and other non-runtime code, e.g. Typescript types. Requires `experimentalAstAwareRemapping: false`.
16391639-16401640-This option works only if the used compiler removes comments and other non-runtime code from the transpiled code.
16411641-By default Vite uses ESBuild which removes comments and Typescript types from `.ts`, `.tsx` and `.jsx` files.
16421642-16431643-If you want to apply ESBuild to other files as well, define them in [`esbuild` options](https://vitejs.dev/config/shared-options.html#esbuild):
16441644-16451645-```ts
16461646-import { defineConfig } from 'vitest/config'
16471647-16481648-export default defineConfig({
16491649- esbuild: {
16501650- // Transpile all files with ESBuild to remove comments from code coverage.
16511651- // Required for `test.coverage.ignoreEmptyLines` to work:
16521652- include: ['**/*.js', '**/*.jsx', '**/*.mjs', '**/*.ts', '**/*.tsx'],
16531653- },
16541654- test: {
16551655- coverage: {
16561656- provider: 'v8',
16571657- ignoreEmptyLines: true,
16581658- },
16591659- },
16601660-})
16611661-```
16621662-#### coverage.experimentalAstAwareRemapping
16631663-16641664-- **Type:** `boolean`
16651665-- **Default:** `false`
16661666-- **Available for providers:** `'v8'`
16671667-- **CLI:** `--coverage.experimentalAstAwareRemapping=<boolean>`
16681668-16691669-Remap coverage with experimental AST based analysis. Provides more accurate results compared to default mode.
16701670-16711631#### coverage.ignoreClassMethods
1672163216731633- **Type:** `string[]`
16741634- **Default:** `[]`
16751675-- **Available for providers:** `'istanbul'`
16351635+- **Available for providers:** `'v8' | 'istanbul'`
16761636- **CLI:** `--coverage.ignoreClassMethods=<method>`
1677163716781638Set to array of class method names to ignore for coverage.
+1-2
docs/guide/coverage.md
···336336337337Both coverage providers have their own ways how to ignore code from coverage reports:
338338339339-- [`v8`](https://github.com/istanbuljs/v8-to-istanbul#ignoring-uncovered-lines)
339339+- [`v8`](https://github.com/AriPerkkio/ast-v8-to-istanbul?tab=readme-ov-file#ignoring-code)
340340- [`istanbul`](https://github.com/istanbuljs/nyc#parsing-hints-ignoring-lines)
341341-- `v8` with [`experimentalAstAwareRemapping: true`](https://vitest.dev/config/#coverage-experimentalAstAwareRemapping) see [ast-v8-to-istanbul | Ignoring code](https://github.com/AriPerkkio/ast-v8-to-istanbul?tab=readme-ov-file#ignoring-code)
342341343342When using TypeScript the source codes are transpiled using `esbuild`, which strips all comments from the source codes ([esbuild#516](https://github.com/evanw/esbuild/issues/516)).
344343Comments which are considered as [legal comments](https://esbuild.github.io/api/#legal-comments) are preserved.
+15
docs/guide/migration.md
···2121})
2222```
23232424+### V8 Code Coverage Major Changes
2525+2626+Vitest's V8 code coverage provider is now using more accurate coverage result remapping logic.
2727+It is expected for users to see changes in their coverage reports when updating from Vitest v3.
2828+2929+In the past Vitest used [`v8-to-istanbul`](https://github.com/istanbuljs/v8-to-istanbul) for remapping V8 coverage results into your source files.
3030+This method wasn't very accurate and provided plenty of false positives in the coverage reports.
3131+We've now developed a new package that utilizes AST based analysis for the V8 coverage.
3232+This allows V8 reports to be as accurate as `@vitest/coverage-istanbul` reports.
3333+3434+- Coverage ignore hints have updated. See [Coverage | Ignoring Code](/guide/coverage.html#ignoring-code).
3535+- `coverage.ignoreEmptyLines` is removed. Lines without runtime code are no longer included in reports.
3636+- `coverage.experimentalAstAwareRemapping` is removed. This option is now enabled by default, and is the only supported remapping method.
3737+- `coverage.ignoreClassMethods` is now supported by V8 provider too.
3838+2439### Removed options `coverage.all` and `coverage.extensions`
25402641In previous versions Vitest included all uncovered files in coverage report by default.