Skip to content

Commit

Permalink
fix: prevent prettier from breaking typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 21, 2021
1 parent a5b753f commit 799e193
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ function snapshot(file: string, contents: string) {
try {
assert.equal(contents, expected);
} catch (err) {
err.snapshot = true;
err.name = err.name.replace(" [ERR_ASSERTION]", "");
err.message = `${path.relative(process.cwd(), file)}\n\n${err.message}`;
if (err instanceof Error) {
(err as any).snapshot = true;
err.name = err.name.replace(" [ERR_ASSERTION]", "");
err.message = `${path.relative(process.cwd(), file)}\n\n${err.message}`;
}

throw err;
}
Expand Down

0 comments on commit 799e193

Please sign in to comment.