Skip to content

Commit

Permalink
fix: C8 sourcemaps (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkatraz committed Dec 29, 2021
1 parent 274203b commit 436d280
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/vitest/src/coverage.ts
Expand Up @@ -131,19 +131,17 @@ export async function reportCoverage(ctx: Vitest) {
const createReport = require('c8/lib/report')
const report = createReport(ctx.config.coverage)

await report.getCoverageMapFromAllCoverageFiles()

// add source maps
Array
.from(ctx.visitedFilesMap.entries())
.filter(i => !i[0].includes('/node_modules/'))
.forEach(([file, map]) => {
const url = pathToFileURL(file).href
const sources = map.sources.length
? map.sources.map(i => pathToFileURL(i).href)
: [url]
report.sourceMapCache[url] = {
data: {
...map,
sources: map.sources.map(i => pathToFileURL(i).href) || [url],
},
data: { ...map, sources },
}
})

Expand Down

0 comments on commit 436d280

Please sign in to comment.