Skip to content

Commit f65d582

Browse files
committed
fix(coverage): v8 to completely ignore CSS requests, just like istanbul
1 parent 1a57f79 commit f65d582

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/coverage-v8/src/provider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { provider } from 'std-env'
1919

2020
import c from 'tinyrainbow'
2121
import { BaseCoverageProvider } from 'vitest/coverage'
22-
import { parseAstAsync } from 'vitest/node'
22+
import { isCSSRequest, parseAstAsync } from 'vitest/node'
2323
import { version } from '../package.json' with { type: 'json' }
2424

2525
export interface ScriptCoverageWithOffset extends Profiler.ScriptCoverage {
@@ -397,7 +397,14 @@ export class V8CoverageProvider extends BaseCoverageProvider<ResolvedCoverageOpt
397397
}
398398
}
399399

400-
if (this.isIncluded(fileURLToPath(result.url))) {
400+
if (
401+
this.isIncluded(fileURLToPath(result.url))
402+
403+
// Ignore CSS requests, e.g. in Vue.
404+
// File extension itself is .vue, but it contains CSS.
405+
// e.g. "Example.vue?vue&type=style&index=0&scoped=f7f04e08&lang.css"
406+
&& !isCSSRequest(result.url)
407+
) {
401408
scriptCoverages.push(result)
402409
}
403410
}

0 commit comments

Comments
 (0)