-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
56 lines (53 loc) · 1.89 KB
/
Copy pathplaywright.config.ts
File metadata and controls
56 lines (53 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { defineConfig, devices } from '@playwright/test';
/**
* Playwright runs against `next build && next start` (a real production server),
* because soft-404s, server-rendered <head> tags, and `X-Robots-Tag` headers
* only behave correctly in a production build — `next dev` papers over them.
*
* Two servers are started from the SAME build output:
*
* - port 3000, DEPLOY_ENV=production -> the indexable production surface.
* - port 3100, DEPLOY_ENV=preview -> a non-production deploy that must
* emit `X-Robots-Tag: noindex, nofollow`.
*
* The preview server proves environment isolation at runtime (proxy.ts reads
* the live env), without needing a second build.
*
* NOTE: `next build` must have already run. CI builds before invoking this;
* locally use `npm run build && npm run test:e2e`.
*/
const PROD_PORT = 3000;
const PREVIEW_PORT = 3100;
const isCI = !!process.env.CI;
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: isCI,
retries: isCI ? 1 : 0,
// In CI: inline GitHub annotations + an HTML report written to
// `playwright-report/` (uploaded as an artifact for post-mortem on failures).
reporter: isCI ? [['github'], ['html', { open: 'never' }]] : 'list',
use: {
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: [
{
command: `DEPLOY_ENV=production SITE_ORIGIN=http://localhost:${PROD_PORT} npm run start -- --port ${PROD_PORT}`,
url: `http://localhost:${PROD_PORT}`,
reuseExistingServer: !isCI,
timeout: 120_000,
},
{
command: `DEPLOY_ENV=preview SITE_ORIGIN=http://localhost:${PREVIEW_PORT} npm run start -- --port ${PREVIEW_PORT}`,
url: `http://localhost:${PREVIEW_PORT}`,
reuseExistingServer: !isCI,
timeout: 120_000,
},
],
});