Skip to content

Commit

Permalink
fix(test): toThrow() === toThrow('') (#16308)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac authored Jan 10, 2025
1 parent 138cf7e commit 5e584e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bun.js/test/expect.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,10 @@ pub const Expect = struct {
break :brk innerConstructorValue;
}
}
} else if (value.isString()) {
// `.toThrow("") behaves the same as `.toThrow()`
const s = value.toString(globalThis);
if (s.length() == 0) break :brk .zero;
}
break :brk value;
};
Expand Down
11 changes: 11 additions & 0 deletions test/cli/test/expectations.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe(".toThrow()", () => {
it(".toThrow() behaves the same as .toThrow('')", () => {
expect(() => {
throw new Error("test");
}).toThrow();

expect(() => {
throw new Error("test");
}).toThrow("");
});
});

0 comments on commit 5e584e9

Please sign in to comment.