aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-07 05:13:54 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-07 05:13:54 -0800
commit370d9c2931bbe778c8f897439d3a5429be933c21 (patch)
tree1e2924e4932c6723135abbd7332425b1e92c1380 /src
parentc00359a521bfcd0d1476511962cfc50763796e61 (diff)
downloadbun-370d9c2931bbe778c8f897439d3a5429be933c21.tar.gz
bun-370d9c2931bbe778c8f897439d3a5429be933c21.tar.zst
bun-370d9c2931bbe778c8f897439d3a5429be933c21.zip
[bun:test] Rejected promises should cause tests to fail
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/test/jest.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 8674e2c22..e33e0fbf2 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -1070,6 +1070,11 @@ pub const TestRunnerTask = struct {
this.sync_state = .pending;
const result = TestScope.run(&test_, this);
+
+ // rejected promises should fail the test
+ if (result != .fail)
+ globalThis.handleRejectedPromises();
+
if (result == .pending and this.sync_state == .pending and (this.done_callback_state == .pending or this.promise_state == .pending)) {
this.sync_state = .fulfilled;
this.value.set(globalThis, this.describe.value);
@@ -1078,6 +1083,10 @@ pub const TestRunnerTask = struct {
this.handleResult(result, .sync);
+ if (result == .fail) {
+ globalThis.handleRejectedPromises();
+ }
+
return false;
}