import { defineConfig, devices } from "@playwright/test"; import { reservePort, TEST_PORT_VARIABLES, testRunPath, testRunRoot, } from "./scripts/lib/run-isolation.ts"; // 1105/12-04. Under TEST_RUN_ID the workshop is built into the run's own // folder (.tmp/runs//artifacts/storybook/static) with build:storybook's // two steps and another output folder, and the results and report are the // run's own. Unset, the gate's build:storybook writes artifacts/storybook/static. // The static server listens on a free port (TEST_STORYBOOK_PORT pins one). const staticDirectory = testRunPath("artifacts/storybook/static"); const port = await reservePort(TEST_PORT_VARIABLES.storybook); const origin = `http://127.0.0.1:${port}`; const buildWorkshop = testRunRoot() === "." ? "corepack pnpm build:storybook" : "node scripts/generate-product-feature-index.ts && " + `corepack pnpm exec storybook build -o ${staticDirectory}`; export default defineConfig({ testDir: "./tests/storybook", forbidOnly: true, outputDir: testRunPath("artifacts/tests/storybook/results"), reporter: [ ["list"], [ "html", { outputFolder: testRunPath("artifacts/tests/storybook/report"), open: "never", }, ], [ "junit", { outputFile: testRunPath("artifacts/tests/storybook/results.xml") }, ], ], use: { baseURL: origin, trace: "retain-on-failure", screenshot: "only-on-failure", }, webServer: { command: `${buildWorkshop} && node scripts/serve-static.ts ${staticDirectory} ${port}`, url: origin, reuseExistingServer: false, }, projects: [ { name: "chromium-workshop", use: { ...devices["Desktop Chrome"] } }, ], });