vscode test runner add the new test functions to static analysis (#25256)

This commit is contained in:
Michael H
2025-12-01 12:31:17 +11:00
committed by GitHub
parent fdcfac6a75
commit 9ca8de6eb9
2 changed files with 37 additions and 6 deletions

View File

@@ -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", () => {

View File

@@ -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",
};