Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bun.js/test/expect/toBeCloseTo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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", .{});
}
Expand Down Expand Up @@ -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;
3 changes: 2 additions & 1 deletion src/bun.js/test/expect/toBeValidDate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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;
3 changes: 2 additions & 1 deletion src/bun.js/test/expect/toContainEqual.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
17 changes: 17 additions & 0 deletions test/internal/ban-words.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { file, Glob } from "bun";
import { readdirSync } from "fs";
import path from "path";

// prettier-ignore
Expand Down Expand Up @@ -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()`,
);
}
});
}
});