Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/runtime/test_runner/Order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ impl Order {
pub fn generate_all_order(&mut self, entries: &[Box<ExecutionEntry>]) -> JsResult<AllOrderResult> {
let start = self.groups.len();
for entry_box in entries.iter() {
if entry_box.callback.is_none() {
// The hook's callback was dropped because its describe is .skip/.todo
// (`ExecutionEntry::create`). Scheduling it would mint a standalone sequence
// with `test_entry = None` that the reporter then prints as a phantom
// "(unnamed)" skipped/todo test.
continue;
}
// Callers (e.g. BunTestRoot.hook_scope) only hold `&` access to the Vec, so we accept
// `&[Box<_>]` and recover each Box's heap pointer as *mut to mutate through the
// pointer, not the slice. SAFETY: each Box<ExecutionEntry> is live and
Expand Down
30 changes: 30 additions & 0 deletions test/cli/test/bun-test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,36 @@ describe("bun test", () => {
expect(stderr).toContain("should run");
});
});
describe("describe.skip / describe.todo", () => {
const fixture = (kind: "skip" | "todo") => `
import { describe, test, beforeAll, afterAll, beforeEach, afterEach } from "bun:test";
describe.${kind}("disabled suite", () => {
beforeAll(() => { console.error("beforeAll ran"); });
afterAll(() => { console.error("afterAll ran"); });
beforeEach(() => {});
afterEach(() => {});
test("the only real test", () => {});
});
`;
for (const kind of ["skip", "todo"] as const) {
test(`should not count beforeAll/afterAll as ${kind} tests`, () => {
const stderr = runTest({ input: fixture(kind) });
expect(stderr).not.toContain("(unnamed)");
expect(stderr).not.toContain("beforeAll ran");
expect(stderr).not.toContain("afterAll ran");
expect(stderr).toContain("the only real test");
expect(stderr).toMatch(new RegExp(`\\b1 ${kind}\\b`));
expect(stderr).toContain("Ran 1 test across 1 file");
});
}
test("should still run beforeAll/afterAll in describe.todo with --todo", () => {
const stderr = runTest({ args: ["--todo"], input: fixture("todo") });
expect(stderr).not.toContain("(unnamed)");
expect(stderr).toContain("beforeAll ran");
expect(stderr).toContain("afterAll ran");
expect(stderr).toContain("Ran 1 test across 1 file");
});
});
describe("only", () => {
test("should run nested describe.only", () => {
const stderr = runTest({
Expand Down
Loading