Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/coverage-istanbul/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,13 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider implements Co
}
}

await fs.rm(this.coverageFilesDirectory, { recursive: true })
this.coverageFiles = new Map()
// In watch mode we need to preserve the previous results if cleanOnRerun is disabled
const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch

if (!keepResults) {
this.coverageFiles = new Map()
await fs.rm(this.coverageFilesDirectory, { recursive: true })
}
}

async getCoverageMapForUncoveredFiles(coveredFiles: string[]) {
Expand Down
9 changes: 7 additions & 2 deletions packages/coverage-v8/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,13 @@ export class V8CoverageProvider extends BaseCoverageProvider implements Coverage
}
}

this.coverageFiles = new Map()
await fs.rm(this.coverageFilesDirectory, { recursive: true })
// In watch mode we need to preserve the previous results if cleanOnRerun is disabled
const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch

if (!keepResults) {
this.coverageFiles = new Map()
await fs.rm(this.coverageFilesDirectory, { recursive: true })
}
}

private async getUntestedFiles(testedFiles: string[]): Promise<RawCoverage> {
Expand Down
Loading