Skip to content

Commit bfb47ab

Browse files
committed
feat!(coverage): support only AST based remapping
1 parent cecc4e0 commit bfb47ab

31 files changed

+328
-1165
lines changed

docs/config/index.md

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,51 +1678,11 @@ Sets thresholds to 100 for files matching the glob pattern.
16781678
}
16791679
```
16801680

1681-
#### coverage.ignoreEmptyLines
1682-
1683-
- **Type:** `boolean`
1684-
- **Default:** `true` (`false` in v1)
1685-
- **Available for providers:** `'v8'`
1686-
- **CLI:** `--coverage.ignoreEmptyLines=<boolean>`
1687-
1688-
Ignore empty lines, comments and other non-runtime code, e.g. Typescript types. Requires `experimentalAstAwareRemapping: false`.
1689-
1690-
This option works only if the used compiler removes comments and other non-runtime code from the transpiled code.
1691-
By default Vite uses ESBuild which removes comments and Typescript types from `.ts`, `.tsx` and `.jsx` files.
1692-
1693-
If you want to apply ESBuild to other files as well, define them in [`esbuild` options](https://vitejs.dev/config/shared-options.html#esbuild):
1694-
1695-
```ts
1696-
import { defineConfig } from 'vitest/config'
1697-
1698-
export default defineConfig({
1699-
esbuild: {
1700-
// Transpile all files with ESBuild to remove comments from code coverage.
1701-
// Required for `test.coverage.ignoreEmptyLines` to work:
1702-
include: ['**/*.js', '**/*.jsx', '**/*.mjs', '**/*.ts', '**/*.tsx'],
1703-
},
1704-
test: {
1705-
coverage: {
1706-
provider: 'v8',
1707-
ignoreEmptyLines: true,
1708-
},
1709-
},
1710-
})
1711-
```
1712-
#### coverage.experimentalAstAwareRemapping
1713-
1714-
- **Type:** `boolean`
1715-
- **Default:** `false`
1716-
- **Available for providers:** `'v8'`
1717-
- **CLI:** `--coverage.experimentalAstAwareRemapping=<boolean>`
1718-
1719-
Remap coverage with experimental AST based analysis. Provides more accurate results compared to default mode.
1720-
17211681
#### coverage.ignoreClassMethods
17221682

17231683
- **Type:** `string[]`
17241684
- **Default:** `[]`
1725-
- **Available for providers:** `'istanbul'`
1685+
- **Available for providers:** `'v8' | 'istanbul'`
17261686
- **CLI:** `--coverage.ignoreClassMethods=<method>`
17271687

17281688
Set to array of class method names to ignore for coverage.

docs/guide/coverage.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,8 @@ export default defineConfig({
281281

282282
Both coverage providers have their own ways how to ignore code from coverage reports:
283283

284-
- [`v8`](https://github.com/istanbuljs/v8-to-istanbul#ignoring-uncovered-lines)
284+
- [`v8`](https://github.com/AriPerkkio/ast-v8-to-istanbul?tab=readme-ov-file#ignoring-code)
285285
- [`istanbul`](https://github.com/istanbuljs/nyc#parsing-hints-ignoring-lines)
286-
- `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)
287286

288287
When 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)).
289288
Comments which are considered as [legal comments](https://esbuild.github.io/api/#legal-comments) are preserved.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
"@sinonjs/[email protected]": "patches/@[email protected]",
8787
8888
"@types/[email protected]": "patches/@[email protected]",
89-
9089
9190
},
9291
"onlyBuiltDependencies": [

packages/coverage-v8/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"@types/test-exclude": "catalog:",
7878
"@vitest/browser": "workspace:*",
7979
"pathe": "catalog:",
80-
"v8-to-istanbul": "^9.3.0",
8180
"vite-node": "workspace:*",
8281
"vitest": "workspace:*"
8382
}

0 commit comments

Comments
 (0)