aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/test/jest.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 7922c4940..6cbfe3226 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -365,6 +365,16 @@ pub const Expect = struct {
);
return js.JSValueMakeUndefined(ctx);
}
+ if (this.scope.tests.items.len <= this.test_id) {
+ JSC.JSError(
+ getAllocator(ctx),
+ ".toBe() called in wrong scope",
+ .{},
+ ctx,
+ exception,
+ );
+ return js.JSValueMakeUndefined(ctx);
+ }
this.scope.tests.items[this.test_id].counter.actual += 1;
const left = JSValue.fromRef(arguments[0]);
left.ensureStillAlive();
@@ -418,6 +428,16 @@ pub const Expect = struct {
);
return js.JSValueMakeUndefined(ctx);
}
+ if (this.scope.tests.items.len <= this.test_id) {
+ JSC.JSError(
+ getAllocator(ctx),
+ ".toHaveLength() called in wrong scope",
+ .{},
+ ctx,
+ exception,
+ );
+ return js.JSValueMakeUndefined(ctx);
+ }
this.scope.tests.items[this.test_id].counter.actual += 1;
const expected = JSC.JSValue.fromRef(arguments[0]).toU32();