Skip to content

Commit

Permalink
fix(coverage): all missing untested files in edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Mar 2, 2024
1 parent 14ee16d commit dfe16e1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,16 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider implements Co
.map(file => resolve(this.ctx.config.root, file))
.filter(file => !coveredFiles.includes(file))

const cacheKey = new Date().getTime()
const coverageMap = libCoverage.createCoverageMap({})

// Note that these cannot be run parallel as synchronous instrumenter.lastFileCoverage
// returns the coverage of the last transformed file
for (const [index, filename] of uncoveredFiles.entries()) {
debug('Uncovered file %s %d/%d', filename, index, uncoveredFiles.length)

// Make sure file is not served from cache
// so that instrumenter loads up requested file coverage
if (this.ctx.vitenode.fetchCache.has(filename))
this.ctx.vitenode.fetchCache.delete(filename)

await this.ctx.vitenode.transformRequest(filename)

// Make sure file is not served from cache so that instrumenter loads up requested file coverage
await this.ctx.vitenode.transformRequest(`${filename}?v=${cacheKey}`)
const lastCoverage = this.instrumenter.lastFileCoverage()
coverageMap.addFileCoverage(lastCoverage)
}
Expand Down

0 comments on commit dfe16e1

Please sign in to comment.