aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-09 03:41:03 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-09 03:41:03 -0800
commit2392e48e9da65dbecdfa9b16446c739c7618e5a1 (patch)
treee5d753dfb145098bda8276a53fe0372fe5ccc340
parent3386afc0bc80974d78e4a9e03b2739655c646f66 (diff)
downloadbun-2392e48e9da65dbecdfa9b16446c739c7618e5a1.tar.gz
bun-2392e48e9da65dbecdfa9b16446c739c7618e5a1.tar.zst
bun-2392e48e9da65dbecdfa9b16446c739c7618e5a1.zip
Fixes https://github.com/oven-sh/bun/issues/1533
-rw-r--r--src/bun.js/test/jest.zig10
-rw-r--r--test/bun.js/test-test.test.ts25
2 files changed, 29 insertions, 6 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 3a281efa3..6882e547b 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -1701,7 +1701,7 @@ pub const DescribeScope = struct {
return scope.run(new_this, ctx, callback, exception);
}
- pub fn run(this: *DescribeScope, thisObject: js.JSObjectRef, ctx: js.JSContextRef, callback: js.JSObjectRef, exception: js.ExceptionRef) js.JSObjectRef {
+ pub fn run(this: *DescribeScope, thisObject: js.JSObjectRef, ctx: js.JSContextRef, callback: js.JSObjectRef, _: js.ExceptionRef) js.JSObjectRef {
if (comptime is_bindgen) return undefined;
js.JSValueProtect(ctx, callback);
defer js.JSValueUnprotect(ctx, callback);
@@ -1720,13 +1720,13 @@ pub const DescribeScope = struct {
switch (prom.status(ctx.ptr().vm())) {
JSPromise.Status.Fulfilled => {},
else => {
- exception.* = prom.result(ctx.ptr().vm()).asObjectRef();
- return null;
+ ctx.bunVM().runErrorHandlerWithDedupe(prom.result(ctx.ptr().vm()), null);
+ return JSC.JSValue.jsUndefined().asObjectRef();
},
}
} else if (result.toError()) |err| {
- exception.* = err.asObjectRef();
- return null;
+ ctx.bunVM().runErrorHandlerWithDedupe(err, null);
+ return JSC.JSValue.jsUndefined().asObjectRef();
}
}
diff --git a/test/bun.js/test-test.test.ts b/test/bun.js/test-test.test.ts
index 9bf1b0b0f..78a701f45 100644
--- a/test/bun.js/test-test.test.ts
+++ b/test/bun.js/test-test.test.ts
@@ -1,4 +1,4 @@
-import { expect, test } from "bun:test";
+import { describe, expect, it, test } from "bun:test";
test("toStrictEqual() vs toEqual()", () => {
expect([1, , 3]).toEqual([1, , 3]);
@@ -1986,3 +1986,26 @@ try {
try {
test();
} catch (e) {}
+
+describe("throw in describe scope doesn't enqueue tests after thrown", () => {
+ it("test enqueued before a describe scope throws is never run", () => {
+ throw new Error("This test failed");
+ });
+
+ class TestPass extends Error {
+ constructor(message) {
+ super(message);
+ this.name = "TestPass";
+ }
+ }
+
+ throw new TestPass("This test passed. Ignore the error message");
+
+ it("test enqueued after a describe scope throws is never run", () => {
+ throw new Error("This test failed");
+ });
+});
+
+it("a describe scope throwing doesn't cause all other tests in the file to fail", () => {
+ expect(true).toBe(true);
+});