-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use
toJSON
for error serialization (#5526)
- Loading branch information
Showing
4 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { test } from "vitest"; | ||
|
||
test("error serialization with toJSON", () => { | ||
throw Object.assign(new Error("hello"), { date: new Date(0) }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from 'vitest' | ||
import { runVitest } from '../../test-utils' | ||
|
||
test('should print logs correctly', async () => { | ||
const result = await runVitest({ root: './fixtures' }, ['error-to-json.test.ts']) | ||
expect(result.stderr).toContain(`Serialized Error: { date: '1970-01-01T00:00:00.000Z' }`) | ||
}) |