From d1e1bc90a9685ee153c17b12ab3d1c99d16d9750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Mon, 20 Nov 2023 09:16:01 +0200 Subject: [PATCH] perf(coverage-istanbul): `all: true` instruments already instrumented files (#4552) --- packages/coverage-istanbul/src/provider.ts | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/coverage-istanbul/src/provider.ts b/packages/coverage-istanbul/src/provider.ts index 5d47794d4113..ea91fc5fa7b7 100644 --- a/packages/coverage-istanbul/src/provider.ts +++ b/packages/coverage-istanbul/src/provider.ts @@ -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