43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import { CI_PLAYWRIGHT_WORKERS, ciWorkers } from "../../scripts/lib/playwright-ci-workers.ts";
|
|
import { configRuns, releaseRuns } from "../helpers/playwright-run-isolation.ts";
|
|
|
|
/**
|
|
* CI-FE-0002. Pin numeric Playwright workers in CI for the e2e config (and the
|
|
* a11y config that spreads it). The capabilities config lives in
|
|
* tests/unit/playwright-capabilities-run-isolation.test.ts so browser-file-storage
|
|
* removal drops it by name (1106/10-01).
|
|
*/
|
|
const runs = configRuns({
|
|
e2e: () => import("../../playwright.config.ts"),
|
|
a11y: () => import("../../playwright.a11y.config.ts"),
|
|
});
|
|
|
|
afterEach(async () => {
|
|
vi.unstubAllEnvs();
|
|
await releaseRuns();
|
|
});
|
|
|
|
describe("CI Playwright workers (CI-FE-0002)", () => {
|
|
it("returns the pinned numeric worker count only when CI=true", () => {
|
|
expect(ciWorkers({ CI: "true" })).toEqual({ workers: CI_PLAYWRIGHT_WORKERS });
|
|
expect(ciWorkers({})).toEqual({});
|
|
expect(ciWorkers({ CI: "" })).toEqual({});
|
|
expect(ciWorkers({ CI: "false" })).toEqual({});
|
|
});
|
|
|
|
it.each(["e2e", "a11y"] as const)(
|
|
"%s sets numeric workers in CI and leaves it undefined outside CI",
|
|
async (name) => {
|
|
vi.stubEnv("CI", "true");
|
|
expect((await runs.load(name)).workers).toBe(CI_PLAYWRIGHT_WORKERS);
|
|
|
|
for (const value of [undefined, "", "false"] as const) {
|
|
vi.stubEnv("CI", value);
|
|
expect((await runs.load(name)).workers).toBeUndefined();
|
|
}
|
|
},
|
|
);
|
|
});
|