diff --git a/src/bun.js/test/expect/toBeCloseTo.zig b/src/bun.js/test/expect/toBeCloseTo.zig index 60fa1496d4..143b3dd636 100644 --- a/src/bun.js/test/expect/toBeCloseTo.zig +++ b/src/bun.js/test/expect/toBeCloseTo.zig @@ -5,6 +5,8 @@ pub fn toBeCloseTo(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallF const thisArguments = callFrame.arguments_old(2); const arguments = thisArguments.ptr[0..thisArguments.len]; + incrementExpectCallCounter(); + if (arguments.len < 1) { return globalThis.throwInvalidArguments("toBeCloseTo() requires at least 1 argument. Expected value must be a number", .{}); } @@ -83,6 +85,7 @@ const jsc = bun.jsc; const CallFrame = bun.jsc.CallFrame; const JSGlobalObject = bun.jsc.JSGlobalObject; const JSValue = bun.jsc.JSValue; +const incrementExpectCallCounter = bun.jsc.Expect.incrementExpectCallCounter; const Expect = bun.jsc.Expect.Expect; const getSignature = Expect.getSignature; diff --git a/src/bun.js/test/expect/toBeValidDate.zig b/src/bun.js/test/expect/toBeValidDate.zig index 560e025f99..f1495377fe 100644 --- a/src/bun.js/test/expect/toBeValidDate.zig +++ b/src/bun.js/test/expect/toBeValidDate.zig @@ -4,7 +4,7 @@ pub fn toBeValidDate(this: *Expect, globalThis: *JSGlobalObject, callFrame: *Cal const thisValue = callFrame.this(); const value: JSValue = try this.getValue(globalThis, thisValue, "toBeValidDate", ""); - bun.jsc.Expect.active_test_expectation_counter.actual += 1; + incrementExpectCallCounter(); const not = this.flags.not; var pass = (value.isDate() and !std.math.isNan(value.getUnixTimestamp())); @@ -32,6 +32,7 @@ const jsc = bun.jsc; const CallFrame = bun.jsc.CallFrame; const JSGlobalObject = bun.jsc.JSGlobalObject; const JSValue = bun.jsc.JSValue; +const incrementExpectCallCounter = bun.jsc.Expect.incrementExpectCallCounter; const Expect = bun.jsc.Expect.Expect; const getSignature = Expect.getSignature; diff --git a/src/bun.js/test/expect/toContainEqual.zig b/src/bun.js/test/expect/toContainEqual.zig index 4cf2f48758..2b1b6537b6 100644 --- a/src/bun.js/test/expect/toContainEqual.zig +++ b/src/bun.js/test/expect/toContainEqual.zig @@ -12,7 +12,7 @@ pub fn toContainEqual( return globalThis.throwInvalidArguments("toContainEqual() takes 1 argument", .{}); } - bun.jsc.Expect.active_test_expectation_counter.actual += 1; + incrementExpectCallCounter(); const expected = arguments[0]; expected.ensureStillAlive(); @@ -108,6 +108,7 @@ const jsc = bun.jsc; const CallFrame = bun.jsc.CallFrame; const JSGlobalObject = bun.jsc.JSGlobalObject; const JSValue = bun.jsc.JSValue; +const incrementExpectCallCounter = bun.jsc.Expect.incrementExpectCallCounter; const Expect = bun.jsc.Expect.Expect; const getSignature = Expect.getSignature; diff --git a/test/internal/ban-words.test.ts b/test/internal/ban-words.test.ts index 8660778656..bc5c90fc01 100644 --- a/test/internal/ban-words.test.ts +++ b/test/internal/ban-words.test.ts @@ -1,4 +1,5 @@ import { file, Glob } from "bun"; +import { readdirSync } from "fs"; import path from "path"; // prettier-ignore @@ -134,3 +135,19 @@ describe("banned words", () => { }); } }); + +describe("required words", () => { + const expectDir = "src/bun.js/test/expect"; + const files = readdirSync(expectDir); + for (const file of files) { + if (!file.endsWith(".zig") || file.startsWith(".") || file === "toHaveReturnedTimes.zig") continue; + test(file, async () => { + const content = await Bun.file(path.join(expectDir, file)).text(); + if (!content.includes("incrementExpectCallCounter")) { + throw new Error( + `${expectDir}/${file} is missing string "incrementExpectCallCounter"\nAll expect() functions must call incrementExpectCallCounter()`, + ); + } + }); + } +});