From 9ca8de6eb901cce47746443c5601f661ef297c9d Mon Sep 17 00:00:00 2001 From: Michael H Date: Mon, 1 Dec 2025 12:31:17 +1100 Subject: [PATCH] vscode test runner add the new test functions to static analysis (#25256) --- .../bun-test-controller.static-parser.test.ts | 35 +++++++++++++++++-- .../src/features/tests/bun-test-controller.ts | 8 ++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/bun-vscode/src/features/tests/__tests__/bun-test-controller.static-parser.test.ts b/packages/bun-vscode/src/features/tests/__tests__/bun-test-controller.static-parser.test.ts index 9adb429bf2..c1e9b2da24 100644 --- a/packages/bun-vscode/src/features/tests/__tests__/bun-test-controller.static-parser.test.ts +++ b/packages/bun-vscode/src/features/tests/__tests__/bun-test-controller.static-parser.test.ts @@ -533,15 +533,19 @@ describe("BunTestController (static file parser)", () => { test.todo("todo test", () => {}); test.only("only test", () => {}); test.failing("failing test", () => {}); + test.concurrent("concurrent test", () => {}); + test.serial("serial test", () => {}); `; const result = parseTestBlocks(content); - expect(result).toHaveLength(4); + expect(result).toHaveLength(6); expect(result[0].name).toBe("skipped test"); expect(result[1].name).toBe("todo test"); expect(result[2].name).toBe("only test"); expect(result[3].name).toBe("failing test"); + expect(result[4].name).toBe("concurrent test"); + expect(result[5].name).toBe("serial test"); }); test("should handle conditional tests", () => { @@ -549,14 +553,41 @@ describe("BunTestController (static file parser)", () => { test.if(true)("conditional test", () => {}); test.skipIf(false)("skip if test", () => {}); test.todoIf(true)("todo if test", () => {}); + test.failingIf(true)("failing if test", () => {}); + test.concurrentIf(true)("concurrent if test", () => {}); + test.serialIf(true)("serial if test", () => {}); `; const result = parseTestBlocks(content); - expect(result).toHaveLength(3); + expect(result).toHaveLength(6); expect(result[0].name).toBe("conditional test"); expect(result[1].name).toBe("skip if test"); expect(result[2].name).toBe("todo if test"); + expect(result[3].name).toBe("failing if test"); + expect(result[4].name).toBe("concurrent if test"); + expect(result[5].name).toBe("serial if test"); + }); + + test("should handle describe modifiers", () => { + const content = ` + describe.concurrent("concurrent describe", () => { + test("test in concurrent", () => {}); + }); + describe.serial("serial describe", () => { + test("test in serial", () => {}); + }); + `; + + const result = parseTestBlocks(content); + + expect(result).toHaveLength(2); + expect(result[0].name).toBe("concurrent describe"); + expect(result[0].type).toBe("describe"); + expect(result[0].children).toHaveLength(1); + expect(result[1].name).toBe("serial describe"); + expect(result[1].type).toBe("describe"); + expect(result[1].children).toHaveLength(1); }); test("should ignore comments", () => { diff --git a/packages/bun-vscode/src/features/tests/bun-test-controller.ts b/packages/bun-vscode/src/features/tests/bun-test-controller.ts index d822d88141..c3b39a673a 100644 --- a/packages/bun-vscode/src/features/tests/bun-test-controller.ts +++ b/packages/bun-vscode/src/features/tests/bun-test-controller.ts @@ -340,7 +340,7 @@ export class BunTestController implements vscode.Disposable { }); const testRegex = - /\b(describe|test|it)(?:\.(?:skip|todo|failing|only))?(?:\.(?:if|todoIf|skipIf)\s*\([^)]*\))?(?:\.each\s*\([^)]*\))?\s*\(\s*(['"`])((?:\\\2|.)*?)\2\s*(?:,|\))/g; + /\b(describe|test|it)(?:\.(?:skip|todo|failing|only|concurrent|serial))*(?:\.(?:if|todoIf|skipIf|failingIf|concurrentIf|serialIf)\s*\([^)]*\))?(?:\.each\s*\([^)]*\))?\s*\(\s*(['"`])((?:\\\2|.)*?)\2\s*(?:,|\))/g; const stack: TestNode[] = []; const root: TestNode[] = []; @@ -1391,7 +1391,7 @@ export class BunTestController implements vscode.Disposable { } const { bunCommand, testArgs } = this.getBunExecutionConfig(); - const args = [...testArgs, ...testFiles]; + const args = [bunCommand, ...testArgs, ...testFiles]; if (!isIndividualTestRun) { args.push("--inspect-brk"); @@ -1416,14 +1416,14 @@ export class BunTestController implements vscode.Disposable { } const debugConfiguration: vscode.DebugConfiguration = { - args: args.slice(1), + args: args.slice(2), console: "integratedTerminal", cwd: "${workspaceFolder}", internalConsoleOptions: "neverOpen", name: "Bun Test Debug", program: args.at(1), request: "launch", - runtime: bunCommand, + runtime: args.at(0), type: "bun", };