Skip to content

Commit

Permalink
chore: check that file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 15, 2023
1 parent 38222d1 commit 9466309
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/utils/src/source-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export function parseSingleV8Stack(raw: string): ParsedStack | null {
// normalize Windows path (\ -> /)
file = resolve(file)

if (method)
method = method.replace(/__vite_ssr_import_\d+__\./g, '')

return {
method,
file,
Expand Down
4 changes: 2 additions & 2 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))
if (!ctx.snapshot.resolvedPaths.has(snapshotPath) || !existsSync(snapshotPath))
return null
return fs.readFile(snapshotPath, 'utf-8')
},
Expand All @@ -86,7 +86,7 @@ export function setup(vitestOrWorkspace: Vitest | WorkspaceProject, server?: Vit
return fs.writeFile(id, content, 'utf-8')
},
async removeSnapshotFile(id) {
if (!ctx.snapshot.resolvedPaths.has(id))
if (!ctx.snapshot.resolvedPaths.has(id) || !existsSync(id))
return
return fs.unlink(id)
},
Expand Down

0 comments on commit 9466309

Please sign in to comment.