Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

playwright.config.ts

50 lines1.2 KB

1import { defineConfig, devices } from '@playwright/test'
2import {
3 appServerReady,
4 appServerReadyPattern,
5} from '@tanstack/router-e2e-utils'
6import { devPort } from './dev-server'
7​
8const PORT = Number(process.env.E2E_APP_PORT ?? 0)
9const baseURL = `http://localhost:${PORT}`
10/**
11 * See https://playwright.dev/docs/test-configuration.
12 */
13export default defineConfig({
14 testDir: './tests',
15 workers: 1,
16​
17 reporter: [['line']],
18​
19 use: {
20 /* Base URL to use in actions like `await page.goto('/')`. */
21 baseURL,
22 },
23​
24 webServer: [
25 {
26 command: `VITE_SERVER_PORT=${PORT} pnpm build && NODE_ENV=production PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`,
27 wait: appServerReady,
28 reuseExistingServer: false,
29 stdout: 'pipe',
30 },
31 {
32 command: `NODE_ENV=development VITE_SERVER_PORT=${devPort} pnpm dev:e2e --host localhost --port ${devPort} --strictPort`,
33 wait: {
34 stdout: new RegExp(
35 appServerReadyPattern.source.replace('E2E_APP_PORT', 'E2E_DEV_PORT'),
36 ),
37 },
38 reuseExistingServer: false,
39 stdout: 'pipe',
40 timeout: 90_000,
41 },
42 ],
43​
44 projects: [
45 {
46 name: 'chromium',
47 use: { ...devices['Desktop Chrome'] },
48 },
49 ],
50})