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

playwright.config.ts

42 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​
17 workers: 1,
18​
19 reporter: [['line']],
20​
21 globalSetup: './tests/setup/global.setup.ts',
22 globalTeardown: './tests/setup/global.teardown.ts',
23​
24 use: {
25 /* Base URL to use in actions like `await page.goto('/')`. */
26 baseURL,
27 },
28​
29 webServer: {
30 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}`,
31 url: baseURL,
32 reuseExistingServer: !process.env.CI,
33 stdout: 'pipe',
34 },
35​
36 projects: [
37 {
38 name: 'chromium',
39 use: { ...devices['Desktop Chrome'] },
40 },
41 ],
42})