From f1f736989717e648ca3eaf33712539e07403d717 Mon Sep 17 00:00:00 2001 From: Will Richards 2 <44687791+will-richards-ii@users.noreply.github.com> Date: Sat, 15 Apr 2023 11:52:46 -0400 Subject: toBeFalsy expect counter and test scope check (#2661) --- src/bun.js/test/jest.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/bun.js/test/jest.zig') diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 3dcecab4c..2c26600c4 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -1478,11 +1478,17 @@ pub const Expect = struct { const thisValue = callFrame.this(); const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); + globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); return .zero; }; value.ensureStillAlive(); + if (this.scope.tests.items.len <= this.test_id) { + globalObject.throw("toBeFalsy() must be called in a test", .{}); + return .zero; + } + active_test_expectation_counter.actual += 1; + const not = this.op.contains(.not); var pass = false; -- cgit v1.2.3