mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
29 lines
600 B
TypeScript
29 lines
600 B
TypeScript
import { expect, spyOn, test } from "bun:test";
|
|
|
|
// This tests that when a mocked function appears in a stack trace
|
|
// It doesn't crash when generating the stack trace.
|
|
test("#8794", () => {
|
|
const target = {
|
|
a() {
|
|
throw new Error("a");
|
|
return 1;
|
|
},
|
|
method() {
|
|
return target.a();
|
|
},
|
|
};
|
|
spyOn(target, "method");
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
try {
|
|
target.method();
|
|
expect.unreachable();
|
|
} catch (e) {
|
|
e.stack;
|
|
expect(e.stack).toContain("at method ");
|
|
expect(e.stack).toContain("at a ");
|
|
}
|
|
Bun.gc(false);
|
|
}
|
|
});
|