Skip to content

Commit

Permalink
perf(coverage-istanbul): all: true instruments already instrumented…
Browse files Browse the repository at this point in the history
… files (#4552)
  • Loading branch information
AriPerkkio authored Nov 20, 2023
1 parent abe6c72 commit d1e1bc9
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,27 +216,13 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider implements Co
.map(file => resolve(this.ctx.config.root, file))
.filter(file => !coveredFiles.includes(file))

const transformResults = await Promise.all(uncoveredFiles.map(async (filename) => {
const transformResult = await this.ctx.vitenode.transformRequest(filename)
return { transformResult, filename }
}))

const coverageMap = libCoverage.createCoverageMap({})

for (const { transformResult, filename } of transformResults) {
const sourceMap = transformResult?.map

if (sourceMap) {
this.instrumenter.instrumentSync(
transformResult.code,
filename,
sourceMap as any,
)
for (const filename of uncoveredFiles) {
await this.ctx.vitenode.transformRequest(filename)

const lastCoverage = this.instrumenter.lastFileCoverage()
if (lastCoverage)
coverageMap.addFileCoverage(lastCoverage)
}
const lastCoverage = this.instrumenter.lastFileCoverage()
coverageMap.addFileCoverage(lastCoverage)
}

return coverageMap.data
Expand Down

0 comments on commit d1e1bc9

Please sign in to comment.