[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(coverage): prevent crash when `cleanOnRerun` is disabled (#5540)

authored by

Ari Perkkiö and committed by
GitHub
(Apr 17, 2024, 2:47 PM +0200) ea3c16e4 df6a4328

+14 -4
+7 -2
packages/coverage-istanbul/src/provider.ts
··· 248 248 } 249 249 } 250 250 251 - await fs.rm(this.coverageFilesDirectory, { recursive: true }) 252 - this.coverageFiles = new Map() 251 + // In watch mode we need to preserve the previous results if cleanOnRerun is disabled 252 + const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch 253 + 254 + if (!keepResults) { 255 + this.coverageFiles = new Map() 256 + await fs.rm(this.coverageFilesDirectory, { recursive: true }) 257 + } 253 258 } 254 259 255 260 async getCoverageMapForUncoveredFiles(coveredFiles: string[]) {
+7 -2
packages/coverage-v8/src/provider.ts
··· 239 239 } 240 240 } 241 241 242 - this.coverageFiles = new Map() 243 - await fs.rm(this.coverageFilesDirectory, { recursive: true }) 242 + // In watch mode we need to preserve the previous results if cleanOnRerun is disabled 243 + const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch 244 + 245 + if (!keepResults) { 246 + this.coverageFiles = new Map() 247 + await fs.rm(this.coverageFilesDirectory, { recursive: true }) 248 + } 244 249 } 245 250 246 251 private async getUntestedFiles(testedFiles: string[]): Promise<RawCoverage> {