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

playwright.config.ts

40 lines1.0 KB

1import { fileURLToPath } from 'node:url'
2import path from 'node:path'
3import { defineConfig, devices } from '@playwright/test'
4import { getTestServerPort } from '@tanstack/router-e2e-utils'
5import packageJson from './package.json' with { type: 'json' }
6​
7// Ensure port file is written next to this config, even if Playwright loads it
8// from a different working directory.
9process.chdir(path.dirname(fileURLToPath(import.meta.url)))
10​
11const PORT = await getTestServerPort(packageJson.name)
12const baseURL = `http://localhost:${PORT}`
13/**
14 * See https://playwright.dev/docs/test-configuration.
15 */
16export default defineConfig({
17 testDir: './tests',
18 workers: 1,
19​
20 reporter: [['line']],
21​
22 use: {
23 /* Base URL to use in actions like `await page.goto('/')`. */
24 baseURL,
25 },
26​
27 webServer: {
28 command: `pnpm build && VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`,
29 url: baseURL,
30 reuseExistingServer: !process.env.CI,
31 stdout: 'pipe',
32 },
33​
34 projects: [
35 {
36 name: 'chromium',
37 use: { ...devices['Desktop Chrome'] },
38 },
39 ],
40})