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

playwright.config.ts

50 lines1.3 KB

1import { defineConfig, devices } from '@playwright/test'
2import { appServerReady } from '@tanstack/router-e2e-utils'
3​
4const toolchain = process.env.E2E_TOOLCHAIN ?? 'vite'
5const inlineCssTransformAssets =
6 process.env.CSS_INLINE_TRANSFORM_ASSETS || 'false'
7if (!['true', 'false'].includes(inlineCssTransformAssets)) {
8 throw new Error(
9 `CSS_INLINE_TRANSFORM_ASSETS must be "true" or "false". Received: ${JSON.stringify(inlineCssTransformAssets)}`,
10 )
12​
13const isInlineCssTransformAssets = inlineCssTransformAssets === 'true'
14const transformAssetsSuffix = isInlineCssTransformAssets
15 ? '-transform-assets'
16 : ''
17const distDir =
18 process.env.E2E_DIST_DIR ?? `dist-${toolchain}${transformAssetsSuffix}-ssr`
19​
20const PORT = Number(process.env.E2E_APP_PORT ?? 0)
21const baseURL = `http://localhost:${PORT}`
22​
23export default defineConfig({
24 testDir: './tests',
25 workers: 1,
26 reporter: [['line']],
27​
28 use: {
29 baseURL,
30 },
31​
32 webServer: {
33 command: `pnpm build:${toolchain} && pnpm start`,
34 wait: appServerReady,
35 reuseExistingServer: false,
36 stdout: 'pipe',
37 env: {
38 E2E_DIST_DIR: distDir,
39 PORT: String(PORT),
40 CSS_INLINE_TRANSFORM_ASSETS: inlineCssTransformAssets,
41 },
42 },
43​
44 projects: [
45 {
46 name: 'chromium',
47 use: { ...devices['Desktop Chrome'] },
48 },
49 ],
50})