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

playwright.config.ts

58 lines1.6 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' }
7import { useExperimentalNonNestedRoutes } from './tests/utils/useExperimentalNonNestedRoutes'
8​
9const PORT = await getTestServerPort(packageJson.name)
10const EXTERNAL_PORT = await getDummyServerPort(packageJson.name)
11const baseURL = `http://localhost:${PORT}`
12const experimentalNonNestedPathsModeCommand = `pnpm build:nonnested && pnpm serve:nonnested --port ${PORT}`
13const defaultCommand = `pnpm build && pnpm serve --port ${PORT}`
14const command = useExperimentalNonNestedRoutes
15 ? experimentalNonNestedPathsModeCommand
16 : defaultCommand
17​
18console.info('Running with mode: ', process.env.MODE || 'default')
19​
20/**
21 * See https://playwright.dev/docs/test-configuration.
22 */
23export default defineConfig({
24 testDir: './tests',
25 workers: 1,
26​
27 reporter: [['line']],
28​
29 globalSetup: './tests/setup/global.setup.ts',
30 globalTeardown: './tests/setup/global.teardown.ts',
31​
32 use: {
33 /* Base URL to use in actions like `await page.goto('/')`. */
34 baseURL,
35 },
36​
37 webServer: {
38 command,
39 url: baseURL,
40 reuseExistingServer: !process.env.CI,
41 stdout: 'pipe',
42 env: {
43 MODE: process.env.MODE || '',
44 VITE_MODE: process.env.MODE || '',
45 VITE_NODE_ENV: 'test',
46 VITE_EXTERNAL_PORT: String(EXTERNAL_PORT),
47 VITE_SERVER_PORT: String(PORT),
48 PORT: String(PORT),
49 },
50 },
51​
52 projects: [
53 {
54 name: 'chromium',
55 use: { ...devices['Desktop Chrome'] },
56 },
57 ],
58})