Skip to content

Commit

Permalink
fix: remove coverage file path query string
Browse files Browse the repository at this point in the history
  • Loading branch information
OrestHk committed Oct 28, 2022
1 parent 6f7fcab commit 6dea179
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/coverage-c8/src/provider.ts
Expand Up @@ -58,7 +58,7 @@ export class C8CoverageProvider implements CoverageProvider {
if (!map)
return

const url = _url.pathToFileURL(file).href.replace(/\?(.*)/, '')
const url = _url.pathToFileURL(file.replace(/\?(.*)/, '')).href

let code: string | undefined
try {
Expand Down Expand Up @@ -86,7 +86,7 @@ export class C8CoverageProvider implements CoverageProvider {
const offset = 224

report._getSourceMap = (coverage: Profiler.ScriptCoverage) => {
const path = _url.pathToFileURL(coverage.url).href.replace(/\?(.*)/, '')
const path = _url.pathToFileURL(coverage.url.replace(/\?(.*)/, '')).href
const data = sourceMapMeta[path]

if (!data)
Expand Down
2 changes: 1 addition & 1 deletion test/coverage-test/coverage-test/coverage.c8.test.ts
Expand Up @@ -39,4 +39,4 @@ test('Should show coverage', async () => {
// For ts and js files
expect(stdout).contain('math.ts')
expect(stdout).contain('utils.js')
})
}, 10000)
1 change: 1 addition & 0 deletions test/coverage-test/vitest.config-c8-coverage.ts
Expand Up @@ -9,6 +9,7 @@ export default defineConfig({
'./coverage-test/c8/**/*test.ts',
],
coverage: {
reporter: ['html', 'text', 'lcov'],
include: ['src/**'],
extension: ['.ts', '.vue', '.js'],
},
Expand Down

0 comments on commit 6dea179

Please sign in to comment.