Files
clean-architecture-frontend…/tests/unit/playwright-capabilities-run-isolation.test.ts

68 lines
2.3 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { CI_PLAYWRIGHT_WORKERS } from "../../scripts/lib/playwright-ci-workers.ts";
import {
configRuns,
describeResultFolders,
describeServerPorts,
hold,
itExitsWhenItsPortIsTaken,
itKeepsTheViteCacheInTheRun,
portOf,
releaseRuns,
} from "../helpers/playwright-run-isolation.ts";
/**
* 1105/12-04 for the capabilities config; why each check exists is in
* tests/unit/playwright-run-isolation.test.ts.
*
* 1106/10-01. This config goes with the browser file/storage runtime:
* test:browser-file-storage-removal deletes it, and deletes this file by
* name with it. Its eight checks used to sit with the other configs and were
* defined only while `existsSync` found the config. test:unit fails on a
* skipped test (1101/10-04), but a test that is never defined is not
* reported: the checks left that drill's copy unnoticed, and a renamed config
* would have taken them out of the template the same way. Imported by name, a
* renamed config fails check:types and this file instead.
*/
const runs = configRuns({
capabilities: () => import("../../playwright.capabilities.config.ts"),
visual: () => import("../../playwright.visual.config.ts"),
});
afterEach(async () => {
vi.unstubAllEnvs();
await releaseRuns();
});
describeResultFolders(runs, [["capabilities", "browser-capabilities"]]);
describe("the build a run serves", () => {
itKeepsTheViteCacheInTheRun(runs, ["capabilities"]);
});
describeServerPorts(runs, ["capabilities"]);
describe("vite servers", () => {
itExitsWhenItsPortIsTaken(runs, ["capabilities"]);
it("no longer share one port between the visual preview and the capability dev server", async () => {
const visual = portOf(await runs.load("visual"));
await hold(visual);
expect(portOf(await runs.load("capabilities"))).not.toBe(visual);
});
});
describe("CI Playwright workers (CI-FE-0002)", () => {
it("sets numeric workers in CI and leaves it undefined outside CI", async () => {
vi.stubEnv("CI", "true");
expect((await runs.load("capabilities")).workers).toBe(CI_PLAYWRIGHT_WORKERS);
for (const value of [undefined, "", "false"] as const) {
vi.stubEnv("CI", value);
expect((await runs.load("capabilities")).workers).toBeUndefined();
}
});
});