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: show error message when cache failed to parse #1614

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/vitest/src/node/cache/results.ts
Expand Up @@ -14,6 +14,10 @@ export class ResultsCache {
private version: string = version
private root = '/'

public getCachePath() {
return this.cachePath
}

setConfig(root: string, config: ResolvedConfig['cache']) {
this.root = root
if (config)
Expand Down
7 changes: 6 additions & 1 deletion packages/vitest/src/node/core.ts
Expand Up @@ -93,7 +93,12 @@ export class Vitest {
await cleanCoverage(resolved.coverage, resolved.coverage.clean)

this.state.results.setConfig(resolved.root, resolved.cache)
await this.state.results.readFromCache()
try {
await this.state.results.readFromCache()
}
catch (err) {
this.error(`[vitest] Error, while trying to parse cache in ${this.state.results.getCachePath()}:`, err)
}
}

getSerializableConfig() {
Expand Down