Repository navigation
bun:test: toThrowErrorMatchingSnapshot stores the message of a thrown object that is not an Error #47999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robobun
wants to merge
1
commit into
main
Choose a base branch
from
robobun/f6aa994e/throw-snapshot-non-error-message
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+367
−5
Open
bun:test: toThrowErrorMatchingSnapshot stores the message of a thrown object that is not an Error #47999
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
test/js/bun/test/snapshot-tests/formats/bun-1.4.4/__snapshots__/thrown.fixture.js.snap
This file contains hidden or 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,37 @@ | ||
| // Bun Snapshot v1, https://bun.sh/docs/test/snapshots | ||
|
|
||
| exports[`an Error 1`] = `"not found"`; | ||
|
|
||
| exports[`an instance of a class that extends Error 1`] = `"not found"`; | ||
|
|
||
| exports[`an Error with a cause 1`] = `"outer"`; | ||
|
|
||
| exports[`an Error with an empty message 1`] = `undefined`; | ||
|
|
||
| exports[`an Error whose message has a getter 1`] = ` | ||
| { | ||
| "total": [native code], | ||
| } | ||
| `; | ||
|
|
||
| exports[`a plain object 1`] = `undefined`; | ||
|
|
||
| exports[`an instance of a class 1`] = `undefined`; | ||
|
|
||
| exports[`an object with a null prototype 1`] = `undefined`; | ||
|
|
||
| exports[`a DOMException 1`] = `undefined`; | ||
|
|
||
| exports[`an object that inherits Error.prototype 1`] = `undefined`; | ||
|
|
||
| exports[`an object with a name 1`] = `undefined`; | ||
|
|
||
| exports[`a rejected promise 1`] = `undefined`; | ||
|
|
||
| exports[`an object with the message 0 1`] = `undefined`; | ||
|
|
||
| exports[`an object with an empty message 1`] = `undefined`; | ||
|
|
||
| exports[`an object with no message 1`] = `undefined`; | ||
|
|
||
| exports[`a string 1`] = `undefined`; |
32 changes: 32 additions & 0 deletions
32
test/js/bun/test/snapshot-tests/formats/bun-1.4.4/thrown.fixture.js
This file contains hidden or 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,32 @@ | ||
| // Bun 1.4.4 wrote the snapshots of this file, here and in __snapshots__/thrown.fixture.js.snap. | ||
| // To add a case, run it under that version. Never update them with a later Bun. | ||
| import { expect, test } from "bun:test"; | ||
|
|
||
| const thrower = value => () => { | ||
| throw value; | ||
| }; | ||
| const both = value => { | ||
| expect(thrower(value)).toThrowErrorMatchingSnapshot(); | ||
| return expect(thrower(value)); | ||
| }; | ||
|
|
||
| test("an Error", () => { both(new Error("not found")).toThrowErrorMatchingInlineSnapshot(`"not found"`); }); | ||
| test("an instance of a class that extends Error", () => { both(new (class HttpError extends Error {})("not found")).toThrowErrorMatchingInlineSnapshot(`"not found"`); }); | ||
| test("an Error with a cause", () => { both(new Error("outer", { cause: new Error("inner") })).toThrowErrorMatchingInlineSnapshot(`"outer"`); }); | ||
| test("an Error with an empty message", () => { both(new Error("")).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an Error whose message has a getter", () => { both(Object.assign(new Error("x"), { message: { get total() { return 1; } } })).toThrowErrorMatchingInlineSnapshot(` | ||
| { | ||
| "total": [native code], | ||
| } | ||
| `); }); | ||
| test("a plain object", () => { both({ message: "not found", code: 4 }).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an instance of a class", () => { both(new (class Failure { constructor(m) { this.message = m; } })("not found")).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an object with a null prototype", () => { both(Object.assign(Object.create(null), { message: "not found" })).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("a DOMException", () => { both(new DOMException("not found", "NotFoundError")).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an object that inherits Error.prototype", () => { both(Object.assign(Object.create(Error.prototype), { message: "not found" })).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an object with a name", () => { both({ name: "HttpError", message: "not found" }).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("a rejected promise", async () => { await expect(Promise.reject({ message: "not found" })).rejects.toThrowErrorMatchingSnapshot(); await expect(Promise.reject({ message: "not found" })).rejects.toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an object with the message 0", () => { both({ message: 0 }).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an object with an empty message", () => { both({ message: "" }).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("an object with no message", () => { both({ code: 4 }).toThrowErrorMatchingInlineSnapshot(`undefined`); }); | ||
| test("a string", () => { both("not found").toThrowErrorMatchingInlineSnapshot(`undefined`); }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.