You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`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)
193
194
194
195
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)).
195
196
Comments which are considered as [legal comments](https://esbuild.github.io/api/#legal-comments) are preserved.
196
197
197
-
For `istanbul` provider you can include a `@preserve` keyword in the ignore hint.
198
+
You can include a `@preserve` keyword in the ignore hint.
198
199
Beware that these ignore hints may now be included in final production build as well.
199
200
200
201
```diff
201
202
-/* istanbul ignore if */
202
203
+/* istanbul ignore if -- @preserve */
203
204
if (condition) {
204
-
```
205
-
206
-
For `v8` this does not cause any issues. You can use `v8 ignore` comments with Typescript as usual:
@@ -209,19 +211,11 @@ export class V8CoverageProvider extends BaseCoverageProvider<ResolvedCoverageOpt
209
211
transform,
210
212
)
211
213
212
-
constconverter=v8ToIstanbul(
214
+
coverageMap.merge(awaitthis.v8ToIstanbul(
213
215
filename.href,
214
216
0,
215
217
sources,
216
-
undefined,
217
-
this.options.ignoreEmptyLines,
218
-
)
219
-
220
-
awaitconverter.load()
221
-
222
-
try{
223
-
// Create a made up function to mark whole file as uncovered. Note that this does not exist in source maps.
224
-
converter.applyCoverage([{
218
+
[{
225
219
ranges: [
226
220
{
227
221
startOffset: 0,
@@ -232,13 +226,8 @@ export class V8CoverageProvider extends BaseCoverageProvider<ResolvedCoverageOpt
232
226
isBlockCoverage: true,
233
227
// This is magical value that indicates an empty report: https://github.com/istanbuljs/v8-to-istanbul/blob/fca5e6a9e6ef38a9cdc3a178d5a6cf9ef82e6cab/lib/v8-to-istanbul.js#LL131C40-L131C40
234
228
functionName: '(empty-report)',
235
-
}])
236
-
}
237
-
catch(error){
238
-
this.ctx.logger.error(`Failed to convert coverage for uncovered ${filename.href}.\n`,error)
239
-
}
240
-
241
-
coverageMap.merge(converter.toIstanbul())
229
+
}],
230
+
))
242
231
243
232
if(debug.enabled){
244
233
clearTimeout(timeout)
@@ -253,6 +242,71 @@ export class V8CoverageProvider extends BaseCoverageProvider<ResolvedCoverageOpt
0 commit comments