Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const port = Number(process.env.PW_PORT ?? 5179);

export default defineConfig({
testDir: "tests/e2e",
globalSetup: "./tests/e2e/warm-up.ts",
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? [["dot"], ["html", { open: "never" }]] : "list",
use: {
Expand All @@ -16,5 +17,6 @@ export default defineConfig({
command: `npm run dev -- --port ${port} --strictPort`,
url: `http://localhost:${port}`,
reuseExistingServer: !process.env.CI,
env: { PW_E2E: "1" },
},
});
23 changes: 23 additions & 0 deletions tests/e2e/warm-up.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { chromium, type FullConfig } from "@playwright/test";

// A route's first request makes the dev server transform its whole module
// graph; under load that outlasts a spec's 5 s expect, so it is paid here once.
const ROUTES = [
["/", "Dashboard"],
["/servo", "Pick a servo in the left pane."],
["/table", "Control table"],
["/live", "Live"],
] as const;

export default async function warmUp(config: FullConfig): Promise<void> {
const browser = await chromium.launch();
try {
const page = await browser.newPage({ baseURL: config.projects[0]?.use.baseURL });
for (const [path, text] of ROUTES) {
await page.goto(`${path}?sim=1`);
await page.getByRole("main").getByText(text, { exact: true }).waitFor({ timeout: 60_000 });
}
} finally {
await browser.close();
}
}
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default defineConfig({
server: {
// The file: dependency lives outside this repo, so dev must be allowed to serve its wasm.
fs: { allow: [".", "../open-servo-core/client/web"] },
// A rebuild of the shared wasm package mid-run hot-swaps the session out from under a spec.
watch: process.env.PW_E2E === "1" ? null : undefined,
},
plugins: [
localDescriptors(),
Expand Down
Loading