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

playwright.config.ts

39 lines993 Bytes

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