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

playwright.config.ts

41 lines1.1 KB

1import { defineConfig, devices } from '@playwright/test'
2import {
3 getDummyServerPort,
4 getTestServerPort,
5} from '@tanstack/router-e2e-utils'
6import packageJson from './package.json' with { type: 'json' }
7​
8const PORT = await getTestServerPort(packageJson.name)
9const EXTERNAL_PORT = await getDummyServerPort(packageJson.name)
10const baseURL = `http://localhost:${PORT}`
11/**
12 * See https://playwright.dev/docs/test-configuration.
13 */
14export default defineConfig({
15 testDir: './tests',
16 workers: 1,
17​
18 reporter: [['line']],
19​
20 globalSetup: './tests/setup/global.setup.ts',
21 globalTeardown: './tests/setup/global.teardown.ts',
22​
23 use: {
24 /* Base URL to use in actions like `await page.goto('/')`. */
25 baseURL,
26 },
27​
28 webServer: {
29 command: `VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} VITE_SERVER_PORT=${PORT} pnpm build && VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} VITE_SERVER_PORT=${PORT} pnpm preview --port ${PORT}`,
30 url: baseURL,
31 reuseExistingServer: !process.env.CI,
32 stdout: 'pipe',
33 },
34​
35 projects: [
36 {
37 name: 'chromium',
38 use: { ...devices['Desktop Chrome'] },
39 },
40 ],
41})