Skip to content

Commit

Permalink
fix: show error message when cache failed to parse (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 8, 2022
1 parent 4176614 commit c5d07b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit c5d07b8

Please sign in to comment.