toBeFalsy expect counter and test scope check (#2661)

This commit is contained in:
Will Richards 2
2023-04-15 11:52:46 -04:00
committed by GitHub
parent 4b3c483cd4
commit f1f7369897

View File

@@ -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;