61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { parseTestOutput } from "../typescript-command-output";
|
|
|
|
describe("parseTestOutput", () => {
|
|
it("parses a passing vitest run", () => {
|
|
const output = `
|
|
RAN v3.2.6 /path
|
|
|
|
✓ src/greet.test.ts (1 test) 1ms
|
|
|
|
Test Files 1 passed (1)
|
|
Tests 1 passed (1)
|
|
Start at 11:12:54
|
|
Duration 308ms
|
|
`;
|
|
|
|
const result = parseTestOutput(output);
|
|
|
|
expect(result.status).toBe("Success");
|
|
expect(result.summary).toContain("1 passed");
|
|
});
|
|
|
|
it("parses a failing vitest run", () => {
|
|
const output = `
|
|
RAN v3.2.6 /path
|
|
|
|
✓ src/greet.test.ts (1 test) 1ms
|
|
✗ src/foo.test.ts (1 test) 2ms
|
|
|
|
Test Files 1 failed (1)
|
|
Tests 1 failed (1)
|
|
Start at 11:15:00
|
|
Duration 400ms
|
|
`;
|
|
|
|
const result = parseTestOutput(output);
|
|
|
|
expect(result.status).toBe("Fail");
|
|
expect(result.summary).toContain("1 failed");
|
|
});
|
|
|
|
it("returns Error and a fallback summary for unrecognised output", () => {
|
|
const result = parseTestOutput("some random output");
|
|
|
|
expect(result.status).toBe("Fail");
|
|
expect(result.summary).toBe("Tests failed");
|
|
});
|
|
|
|
it("returns Success with a fallback summary when passed but no detail line", () => {
|
|
const output = `
|
|
✓ src/greet.test.ts (1 test) 1ms
|
|
Tests 1 passed (242ms)
|
|
`;
|
|
|
|
const result = parseTestOutput(output);
|
|
|
|
expect(result.status).toBe("Success");
|
|
expect(result.summary).toBe("All tests passed");
|
|
});
|
|
});
|