Skip to content

Commit

Permalink
fix: check snapshot correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 15, 2023
1 parent 278cb4a commit 38222d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vitest/src/api/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function setup(vitestOrWorkspace: Vitest | WorkspaceProject, server?: Vit
return ctx.snapshot.resolveRawPath(testPath, rawPath)
},
async readSnapshotFile(snapshotPath) {
if (!ctx.snapshot.resolvedPaths.has(snapshotPath) || !existsSync(snapshotPath))
if (!ctx.snapshot.resolvedPaths.has(snapshotPath))
return null
return fs.readFile(snapshotPath, 'utf-8')
},
Expand All @@ -80,13 +80,13 @@ export function setup(vitestOrWorkspace: Vitest | WorkspaceProject, server?: Vit
return fs.readFile(id, 'utf-8')
},
async saveSnapshotFile(id, content) {
if (!ctx.state.filesMap.has(id))
if (!ctx.snapshot.resolvedPaths.has(id))
return
await fs.mkdir(dirname(id), { recursive: true })
return fs.writeFile(id, content, 'utf-8')
},
async removeSnapshotFile(id) {
if (!ctx.state.filesMap.has(id) || !existsSync(id))
if (!ctx.snapshot.resolvedPaths.has(id))
return
return fs.unlink(id)
},
Expand Down

0 comments on commit 38222d1

Please sign in to comment.