Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
814 lines (804 loc) · 31.5 KB
/
Copy pathplaywright.config.ts
File metadata and controls
814 lines (804 loc) · 31.5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
import { defineConfig, type Project } from "@playwright/test";
const appRouterBrowserSpecificTests = "**/app-router/**/*.browser.spec.ts";
const appRouterServer = {
command: "npx vp dev --port 4174",
cwd: "./tests/fixtures/app-basic",
port: 4174,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
};
// Dedicated server for BFCache/cacheComponents coverage. cacheComponents is an
// opt-in semantic mode that retains inactive route trees as hidden Activity DOM.
// Running it on the shared app-basic fixture would change the DOM contract for
// every unrelated app-router test, so it gets its own isolated fixture instead.
const appRouterBfcacheServer = {
command: "npx vp dev --port 4183",
cwd: "./tests/fixtures/app-bfcache",
port: 4183,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
};
// Port of next-intl's App Router playground, built for Workers and served
// through Miniflare. Like upstream, each NEXT_PUBLIC_USE_CASE gets its own build
// and runs only its own spec file. Preview binds IPv4 because the domain specs
// map their hostnames to 127.0.0.1.
function cloudflareNextIntlProject(useCase: string, port: number) {
return {
testDir: "./tests/e2e",
testMatch: [`**/cloudflare-next-intl/${useCase}.spec.ts`],
use: { baseURL: `http://localhost:${port}` },
server: {
command: `NEXT_PUBLIC_USE_CASE=${useCase} npx vp build && NEXT_PUBLIC_USE_CASE=${useCase} npx vp preview --host 127.0.0.1 --port ${port}`,
cwd: "./tests/fixtures/cf-next-intl",
port,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
};
}
/**
* Each project maps to a single webServer. Some browser-specific projects share
* a server with the base project, and shared servers are de-duped by port.
* Browser-specific production tests may opt out with server: null when they own
* their build/server lifecycle inside the test fixture.
* When PLAYWRIGHT_PROJECT is set
* (e.g. in CI matrix jobs), only that project and its server are configured,
* so each CI runner only starts the one server it needs.
* Specs matched by isolatedTestMatch run in a separate `<name>-isolated`
* project after the rest of the project finishes, whether it passed or not.
*/
const projectServers = {
"pages-router": {
testDir: "./tests/e2e/pages-router",
// Fast Refresh specs write syntax errors into fixture pages on the shared
// dev server. Vite broadcasts those errors and vinext sends full reloads to
// every open page, so they must not run alongside other specs.
isolatedTestMatch: ["**/pages-router/hmr.spec.ts"],
use: { baseURL: "http://localhost:4173" },
server: {
command: "npx vp run vinext#build && npx vp dev --port 4173",
cwd: "./tests/fixtures/pages-basic",
port: 4173,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"app-router": {
testDir: "./tests/e2e",
testMatch: ["**/app-router/**/*.spec.ts", "**/og-image.spec.ts"],
testIgnore: [
appRouterBrowserSpecificTests,
"**/app-router/nextjs-compat/client-cache.spec.ts",
"**/app-router/nextjs-compat/prefetch-redirect.spec.ts",
"**/app-router/nextjs-compat/route-handler-draft-cache.spec.ts",
"**/app-router/nextjs-compat/segment-cache-client-params.spec.ts",
"**/app-router/isr.spec.ts",
],
use: { baseURL: "http://localhost:4174" },
server: appRouterServer,
},
"app-router-isr-prod": {
testDir: "./tests/e2e",
testMatch: [
"app-router/action-bound-args.spec.ts",
"app-router/isr.spec.ts",
"app-router/metadata-react-cache.spec.ts",
"app-router-prod/action-error-sanitization.spec.ts",
"app-router-prod/special-error-navigation.spec.ts",
"app-router-prod/static-hydration.spec.ts",
"app-router-prod/use-cache.spec.ts",
"app-router-prod/public-file-encoding.spec.ts",
"app-router-prod/image-middleware.spec.ts",
"app-router-prod/pages-res-revalidate.spec.ts",
"app-router-prod/same-origin-absolute-href-prefetch.spec.ts",
"app-router/preload-rejection.spec.ts",
"app-router/external-rewrite-host-capture.spec.ts",
],
use: { baseURL: "http://localhost:4198" },
server: {
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4198",
cwd: "./tests/fixtures/app-basic",
port: 4198,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"app-router-client-cache": {
testDir: "./tests/e2e/app-router/nextjs-compat",
testMatch: [
"client-cache.spec.ts",
"prefetch-redirect.spec.ts",
"route-handler-draft-cache.spec.ts",
"segment-cache-client-params.spec.ts",
],
use: { baseURL: "http://localhost:4191" },
server: {
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4191",
cwd: "./tests/fixtures/app-basic",
port: 4191,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"app-router-chrome-browser-specific": {
testDir: "./tests/e2e",
testMatch: [appRouterBrowserSpecificTests],
use: {
browserName: "chromium" as const,
channel: "chrome" as const,
},
server: null,
},
"app-router-webkit-browser-specific": {
testDir: "./tests/e2e",
testMatch: [appRouterBrowserSpecificTests],
use: { browserName: "webkit" as const },
server: null,
},
"app-router-bfcache": {
testDir: "./tests/e2e/app-router-bfcache",
use: { baseURL: "http://localhost:4183" },
server: appRouterBfcacheServer,
},
"catch-error": {
testDir: "./tests/e2e/catch-error",
use: { baseURL: "http://localhost:4185" },
server: {
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4185",
cwd: "./tests/fixtures/global-not-found-basic",
port: 4185,
reuseExistingServer: false,
timeout: 60_000,
},
},
"cloudflare-pages-router": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-pages-router/**/*.spec.ts",
"**/pages-router/instrumentation-startup.spec.ts",
],
use: { baseURL: "http://localhost:4177" },
server: {
command: "VINEXT_E2E_REVALIDATION_PROXY=1 npx vp build && npx wrangler dev --port 4177",
cwd: "./examples/pages-router-cloudflare",
port: 4177,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"pages-router-prod": {
testDir: "./tests/e2e/pages-router-prod",
server: {
// Use node to invoke the CLI directly — npx vinext may not be on PATH
// in fixture subdirectories since vinext is a workspace dependency.
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4175",
cwd: "./tests/fixtures/pages-basic",
port: 4175,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
env: { NEXT_DEPLOYMENT_ID: "pages-production-deployment" },
},
},
"pages-scroll-restoration": {
testDir: "./tests/e2e/pages-scroll-restoration",
use: { baseURL: "http://localhost:4185" },
server: {
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4185",
cwd: "./tests/fixtures/pages-scroll-restoration",
port: 4185,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-workers": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-workers/**/*.spec.ts",
"**/cloudflare-response-store.spec.ts",
"**/app-router/instrumentation.spec.ts",
"**/og-image.spec.ts",
],
use: { baseURL: process.env.VINEXT_E2E_BASE_URL ?? "http://localhost:4176" },
server: process.env.VINEXT_E2E_BASE_URL
? null
: {
// Build app-router-cloudflare with Vite, then serve with wrangler dev (miniflare)
command:
"VINEXT_RESPONSE_STORE_E2E=1 npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4176",
cwd: "./examples/app-router-cloudflare",
port: 4176,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-sentry-app": {
testDir: "./tests/e2e",
testMatch: ["**/cloudflare-sentry-app/**/*.spec.ts"],
use: { baseURL: "http://localhost:4193" },
server: {
// Exercise the built Worker through Miniflare without Wrangler's extra
// development proxy, which can exit when a browser connection resets.
command:
"NEXT_PUBLIC_VINEXT_TEST_SENTRY_DSN=http://public@localhost:4193/1 npx vp build && npx vp preview --port 4193",
cwd: "./tests/fixtures/cf-sentry-app",
port: 4193,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-next-intl": cloudflareNextIntlProject("main", 4223),
"cloudflare-next-intl-locale-prefix-never": cloudflareNextIntlProject(
"locale-prefix-never",
4231,
),
"cloudflare-next-intl-trailing-slash": cloudflareNextIntlProject("trailing-slash", 4232),
"cloudflare-next-intl-base-path": cloudflareNextIntlProject("base-path", 4233),
"cloudflare-next-intl-domains": cloudflareNextIntlProject("domains", 4234),
"cloudflare-next-intl-domains-locale-prefix": cloudflareNextIntlProject(
"domains-locale-prefix",
4235,
),
"cloudflare-next-intl-locale-cookie-false": cloudflareNextIntlProject(
"locale-cookie-false",
4236,
),
// Port of next-intl's canonical App Router example (static rendering with
// `setRequestLocale`), built for Workers and served through Miniflare.
"cloudflare-next-intl-example": {
testDir: "./tests/e2e/cloudflare-next-intl-example",
use: { baseURL: "http://localhost:4237" },
server: {
command: "npx vp build && npx vp preview --port 4237",
cwd: "./tests/fixtures/cf-next-intl-example",
port: 4237,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"cloudflare-sentry-app-workers-cache": {
testDir: "./tests/e2e",
testMatch: ["**/cloudflare-sentry-app/**/*.spec.ts"],
grep: /cached RSC payload|response start for an App Page cache hit|trace metadata from static HTML/,
use: { baseURL: "http://localhost:4210" },
server: {
command:
"VINEXT_SENTRY_CACHE=workers NEXT_PUBLIC_VINEXT_TEST_SENTRY_DSN=http://public@localhost:4210/1 npx vp build && npx wrangler dev --config .vinext/workers-cache/server/wrangler.json --port 4210",
cwd: "./tests/fixtures/cf-sentry-app",
port: 4210,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-sentry-pages": {
testDir: "./tests/e2e",
testMatch: ["**/cloudflare-sentry-pages/**/*.spec.ts"],
use: { baseURL: "http://localhost:4194" },
server: {
command:
"NEXT_PUBLIC_VINEXT_TEST_SENTRY_DSN=http://public@localhost:4194/1 npx vp build && npx wrangler dev --port 4194",
cwd: "./tests/fixtures/cf-sentry-pages",
port: 4194,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"sentry-nextjs-16-static": {
testDir: "./tests/e2e/sentry-nextjs-16-static/fixture/tests",
use: { baseURL: "http://localhost:3030" },
server: {
command:
"test -e node_modules && npx vp run vinext#build && node ../../../../packages/vinext/dist/cli.js build && node ../../../../packages/vinext/dist/cli.js start --port 3030 --hostname ::",
cwd: "./tests/e2e/sentry-nextjs-16-static/fixture",
port: 3030,
reuseExistingServer: false,
timeout: 120_000,
env: {
NEXT_PUBLIC_E2E_TEST_DSN: "http://public@localhost:3031/1",
PORT: "3030",
TEST_ENV: "production",
},
},
additionalServers: [
{
command: "node event-proxy.mjs",
cwd: "./tests/e2e/sentry-nextjs-16-static/fixture",
port: 3031,
reuseExistingServer: false,
timeout: 30_000,
},
],
},
"cloudflare-dev": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-dev/**/*.spec.ts",
"**/cloudflare-response-store.spec.ts",
"**/app-router/instrumentation.spec.ts",
"**/og-image.spec.ts",
],
use: { baseURL: "http://localhost:4178" },
server: {
// Run vite dev (not wrangler) against the cloudflare example so that
// configureServer() is exercised with @cloudflare/vite-plugin loaded.
command: "VINEXT_RESPONSE_STORE_E2E=1 npx vp dev --port 4178",
cwd: "./examples/app-router-cloudflare",
port: 4178,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"cloudflare-pages-router-dev": {
testDir: "./tests/e2e",
testMatch: [
"**/cloudflare-pages-router-dev/**/*.spec.ts",
"**/cloudflare-pages-router/middleware-data-guard.spec.ts",
"**/pages-router/instrumentation-startup.spec.ts",
],
use: { baseURL: "http://localhost:4179" },
server: {
// Cover the Worker request stage with raw `_next/data` URLs reaching
// middleware; the production project keeps the default config.
command: "VINEXT_E2E_SKIP_PROXY_URL_NORMALIZE=1 npx vp dev --force --port 4179",
cwd: "./examples/pages-router-cloudflare",
port: 4179,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"static-export": {
testDir: "./tests/e2e/static-export",
use: { baseURL: "http://localhost:4180" },
server: {
// Build the static export fixture, then serve the output with a
// lightweight static file server. No vinext runtime is needed —
// the output is pure pre-rendered HTML files.
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../tests/e2e/static-export/serve-static.mjs dist/client 4180",
cwd: "./tests/fixtures/static-export",
port: 4180,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-static-assets": {
testDir: "./tests/e2e/cloudflare-static-assets",
use: { baseURL: process.env.VINEXT_E2E_BASE_URL ?? "http://localhost:4214" },
server: process.env.VINEXT_E2E_BASE_URL
? null
: {
// Vite's build lifecycle prerenders and packages the Static Assets cache.
command:
"npx vp run vinext#build && npx vp run @vinext/cloudflare#build && npx vp run build && npx vite preview --port 4214",
cwd: "./examples/static-assets-cache",
port: 4214,
reuseExistingServer: !process.env.CI,
timeout: 180_000,
},
},
"cloudflare-static-assets-pages": {
testDir: "./tests/e2e/cloudflare-static-assets-pages",
use: { baseURL: process.env.VINEXT_E2E_BASE_URL ?? "http://localhost:4218" },
// Deployed runs set VINEXT_E2E_I18N_BASE_URL for the companion example.
server: process.env.VINEXT_E2E_BASE_URL
? null
: {
// Local builds enable the preview/revalidation test controls.
command:
"npx vp run vinext#build && npx vp run @vinext/cloudflare#build && VINEXT_E2E_CONTROLS=1 npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4218",
cwd: "./examples/static-assets-pages",
port: 4218,
reuseExistingServer: !process.env.CI,
timeout: 180_000,
},
additionalServers: process.env.VINEXT_E2E_BASE_URL
? []
: [
{
command:
"npx vp run vinext#build && npx vp run @vinext/cloudflare#build && npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4219",
cwd: "./examples/static-assets-pages-i18n",
port: 4219,
reuseExistingServer: !process.env.CI,
timeout: 180_000,
},
],
},
"cloudflare-static-export": {
testDir: "./tests/e2e/cloudflare-static-export",
use: { baseURL: "http://localhost:4215" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../../../../examples/app-router-cloudflare/node_modules node_modules) && npx vp run vinext#build && npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4215",
cwd: "./tests/e2e/cloudflare-static-export/fixture",
port: 4215,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"static-export-basepath": {
testDir: "./tests/e2e/static-export-basepath",
use: { baseURL: "http://localhost:4203/docs" },
server: {
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../tests/e2e/static-export/serve-static.mjs dist/client 4203",
cwd: "./tests/fixtures/static-export-basepath",
port: 4203,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"app-router-nitro": {
testDir: "./tests/e2e/app-router-nitro",
testMatch: ["preview.spec.ts"],
use: { baseURL: "http://localhost:4216" },
server: {
// `vite preview` serves Nitro's own build output. vinext must turn off
// @vitejs/plugin-rsc's preview handler, which would otherwise import an
// RSC build from dist/server that Nitro never writes.
command: "npx vp run vinext#build && npx vp build && npx vp preview --port 4216 --strictPort",
cwd: "./examples/app-router-nitro",
port: 4216,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"app-router-nitro-dev": {
testDir: "./tests/e2e/app-router-nitro",
testMatch: ["dev.spec.ts"],
use: { baseURL: "http://localhost:4217" },
server: {
command: "npx vp dev --port 4217 --strictPort",
cwd: "./examples/app-router-nitro",
port: 4217,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"app-with-src": {
testDir: "./tests/e2e/app-with-src",
use: { baseURL: "http://localhost:4181" },
server: {
command: "npx vp dev --port 4181",
cwd: "./tests/fixtures/app-with-src",
port: 4181,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"standalone-output": {
testDir: "./tests/e2e/standalone-output",
use: { baseURL: "http://localhost:4182" },
server: {
// Build vinext CLI, then build the fixture, then start the standalone
// server from an isolated temp directory. Moving it outside the repo
// prevents Node from resolving missing externals from workspace
// node_modules and verifies the standalone package is self-contained.
command:
'npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && standalone_dir="$(mktemp -d)" && cp -R dist/standalone/. "$standalone_dir" && PORT=4182 node "$standalone_dir/server.js"',
cwd: "./tests/fixtures/standalone-output",
port: 4182,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"root-layout-redirect": {
testDir: "./tests/e2e/root-layout-redirect",
use: { baseURL: "http://localhost:4184" },
server: {
// Build vinext CLI, then build the fixture, then start the production
// server. This exercises prodOnCaughtError (the fixed code path) rather
// than devOnCaughtError, which already filtered navigation-signal errors
// before this PR.
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4184",
cwd: "./tests/fixtures/root-layout-redirect",
port: 4184,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"use-params-app-pages": {
testDir: "./tests/e2e/use-params-app-pages",
use: { baseURL: "http://localhost:4186" },
server: {
command:
"cd ../../.. && npx vp run vinext#build && cd tests/fixtures/use-params-app-pages && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4186",
cwd: "./tests/fixtures/use-params-app-pages",
port: 4186,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"ppr-impact-demo": {
testDir: "./tests/e2e/ppr-impact-demo",
use: { baseURL: "http://localhost:4187" },
server: {
command:
"npx vp run vinext#build && npx vp build && node embed-cacheability-manifest.mjs && npx wrangler dev --config dist/server/wrangler.json --port 4187",
cwd: "./tests/fixtures/ppr-impact-demo",
port: 4187,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"cacheability-components": {
testDir: "./tests/e2e/cacheability-components",
use: { baseURL: "http://localhost:4209" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../../../fixtures/ppr-impact-demo/node_modules node_modules) && npx vp run vinext#build && node ../../../../packages/vinext/dist/cli.js build && npx wrangler dev --config dist/server/wrangler.json --port 4209",
cwd: "./tests/e2e/cacheability-components/fixture",
port: 4209,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"app-front-redirect-issue": {
testDir: "./tests/e2e/app-front-redirect-issue",
use: { baseURL: "http://localhost:4188" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../../../fixtures/app-basic/node_modules node_modules) && npx vp run vinext#build && NEXT_DEPLOYMENT_ID=vinext-front-redirect-e2e node ../../../../packages/vinext/dist/cli.js build && NEXT_DEPLOYMENT_ID=vinext-front-redirect-e2e node ../../../../packages/vinext/dist/cli.js start --port 4188",
cwd: "./tests/e2e/app-front-redirect-issue/fixture",
port: 4188,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"pages-router-basepath-dev": {
testDir: "./tests/e2e/pages-router-basepath-dev",
use: { baseURL: "http://localhost:4189" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../pages-basic/node_modules node_modules) && npx vp dev --port 4189",
cwd: "./tests/fixtures/pages-basepath-dev",
port: 4189,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"pages-router-basepath": {
// basePath + trailingSlash. Runs in PROD mode (build + start) because
// vinext's dev server has a Vite html-proxy / basePath incompatibility
// in inline hydration imports — unrelated to the navigation pipeline
// under test. Prod skips html-proxy entirely (it uses pre-built
// `__VINEXT_PAGE_LOADERS__`), so we exercise the same Pages Router
// navigation code paths users hit in production.
testDir: "./tests/e2e/pages-router-basepath",
use: { baseURL: "http://localhost:4190" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../pages-basic/node_modules node_modules) && npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4190",
cwd: "./tests/fixtures/pages-basepath-trailing-slash",
port: 4190,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"app-router-prefetch-searchparams": {
testDir: "./tests/e2e/app-router-prefetch-searchparams",
use: { baseURL: "http://localhost:4191" },
server: {
command:
"npx vp run vinext#build && node ../../../packages/vinext/dist/cli.js build && node ../../../packages/vinext/dist/cli.js start --port 4191",
cwd: "./tests/fixtures/app-basic",
port: 4191,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"app-router-encoded-basepath-i18n": {
testDir: "./tests/e2e/app-router-encoded-basepath-i18n",
use: { baseURL: "http://localhost:4196" },
server: process.env.VINEXT_BASEPATH_E2E_BASE_URL
? undefined
: {
command:
"VINEXT_ENCODED_PATH_BASEPATH_I18N=1 npx vp run vinext#build && VINEXT_ENCODED_PATH_BASEPATH_I18N=1 node ../../../packages/vinext/dist/cli.js build && VINEXT_ENCODED_PATH_BASEPATH_I18N=1 node ../../../packages/vinext/dist/cli.js start --port 4196",
cwd: "./tests/fixtures/app-basic",
port: 4196,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"pages-router-complex": {
// Compatibility target exercising the convoluted patterns of large,
// long-lived Pages Router apps (examples/pages-router-complex). The specs
// document behaviour verified against real Next.js (`pnpm dev:next` in
// the example). Known vinext gaps are marked test.fixme so the passing
// compatibility surface remains enforced in CI. Run it with:
// PLAYWRIGHT_PROJECT=pages-router-complex pnpm run test:e2e
testDir: "./tests/e2e/pages-router-complex",
use: { baseURL: "http://localhost:4199" },
server: {
command: "npx vp dev --port 4199",
cwd: "./examples/pages-router-complex",
port: 4199,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
env: {
ATLAS_PURGE_BEARER: "e2e-purge-token",
// Parity gap: vinext invokes generateBuildId at dev startup; Next.js
// only calls it at build time.
RELEASE_TAG: "e2e",
},
},
},
"cloudflare-encoded-paths": {
testDir: "./tests/e2e/cloudflare-encoded-paths",
use: { baseURL: "http://localhost:4197" },
server: {
command:
"CF_APP_BASIC_RUN_WORKER_FIRST=1 npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4197",
cwd: "./tests/fixtures/cf-app-basic",
port: 4197,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-dev-run-worker-first": {
testDir: "./tests/e2e/cloudflare-dev-run-worker-first",
use: { baseURL: "http://localhost:4204" },
server: {
// Dev with the runWorkerFirst pattern that `vinext init` generates
command: "CF_APP_BASIC_RUN_WORKER_FIRST=1 npx vp dev --port 4204",
cwd: "./tests/fixtures/cf-app-basic",
port: 4204,
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
},
"web-worker-vinext": {
testDir: "./tests/e2e/web-worker",
use: { baseURL: "http://localhost:4200" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../../../../fixtures/app-basic/node_modules node_modules) && npx vp run vinext#build && node ../../../../../packages/vinext/dist/cli.js build && node ../../../../../packages/vinext/dist/cli.js start --port 4200",
cwd: "./tests/e2e/web-worker/fixtures/vinext",
port: 4200,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"web-worker-cloudflare": {
testDir: "./tests/e2e/web-worker",
use: { baseURL: "http://localhost:4201" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../../../../fixtures/cf-app-basic/node_modules node_modules) && npx vp run vinext#build && npx vp build && npx wrangler dev --config dist/server/wrangler.json --port 4201",
cwd: "./tests/e2e/web-worker/fixtures/cloudflare",
port: 4201,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
"module-federation": {
testDir: "./tests/e2e/module-federation",
use: { baseURL: "http://localhost:4220" },
server: {
command: "npx vp run vinext#build && npx vp build && npx vp preview --port 4220 --strictPort",
cwd: "./tests/fixtures/module-federation-host",
port: 4220,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
// Playwright starts web servers in order, so vinext is built before the
// remote imports vinext/client.
additionalServers: [
{
command: "npx vp build && npx vp preview --port 4221 --strictPort",
cwd: "./tests/fixtures/module-federation-remote",
port: 4221,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
],
},
"module-federation-cloudflare": {
testDir: "./tests/e2e/module-federation",
use: { baseURL: "http://localhost:4222" },
server: {
command:
"npx vp run vinext#build && npx vp build --config vite.cloudflare.config.ts && npx wrangler dev --config dist/server/wrangler.json --port 4222",
cwd: "./tests/fixtures/module-federation-host",
port: 4222,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
additionalServers: [
{
command: "npx vp build && npx vp preview --port 4221 --strictPort",
cwd: "./tests/fixtures/module-federation-remote",
port: 4221,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
],
},
"nextjs-worker-cloudflare": {
testDir: "./tests/e2e/nextjs-worker",
use: { baseURL: "http://localhost:4202" },
server: {
command:
"(test -e node_modules || test -L node_modules || ln -s ../../../fixtures/cf-app-basic/node_modules node_modules) && npx vp run vinext#build && NEXT_DEPLOYMENT_ID=test-deployment-id npx vp build && NEXT_DEPLOYMENT_ID=test-deployment-id npx wrangler dev --config dist/server/wrangler.json --port 4202",
cwd: "./tests/e2e/nextjs-worker/fixture",
port: 4202,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
},
};
type ProjectName = keyof typeof projectServers;
const selected = process.env.PLAYWRIGHT_PROJECT;
if (selected && !(selected in projectServers)) {
throw new Error(
`Unknown PLAYWRIGHT_PROJECT: "${selected}". ` +
`Valid: ${Object.keys(projectServers).join(", ")}`,
);
}
const activeProjects: ProjectName[] = selected
? [selected as ProjectName]
: (Object.keys(projectServers) as ProjectName[]);
if (activeProjects.includes("sentry-nextjs-16-static")) {
process.env.TEST_ENV = "production";
}
export default defineConfig({
testDir: "./tests/e2e",
timeout: 30_000,
retries: 1,
// GitHub reporter adds inline failure annotations in PR diffs.
reporter: process.env.CI ? [["list"], ["github"]] : [["list"]],
use: {
headless: true,
// Most projects use Chromium by default. Browser-specific projects override this.
browserName: "chromium",
},
projects: activeProjects.flatMap((name): Project[] => {
const p = projectServers[name];
const isolatedTestMatch = "isolatedTestMatch" in p ? p.isolatedTestMatch : [];
const testIgnore = [...("testIgnore" in p ? p.testIgnore : []), ...isolatedTestMatch];
const project = {
name,
testDir: p.testDir,
...("testMatch" in p ? { testMatch: p.testMatch } : {}),
...(testIgnore.length > 0 ? { testIgnore } : {}),
...("grep" in p ? { grep: p.grep } : {}),
...("use" in p ? { use: p.use } : {}),
};
if (isolatedTestMatch.length === 0) return [project];
// A teardown project runs once its setup project and all of that project's
// dependents finish, even when they fail, unlike a dependent project.
const isolatedName = `${name}-isolated`;
return [
{ ...project, teardown: isolatedName },
{
name: isolatedName,
testDir: p.testDir,
testMatch: isolatedTestMatch,
...("use" in p ? { use: p.use } : {}),
},
];
}),
webServer: [
...new Map(
activeProjects
.flatMap((name) => {
const project = projectServers[name];
return [
project.server,
...("additionalServers" in project ? project.additionalServers : []),
];
})
.filter(
(server): server is NonNullable<(typeof projectServers)[ProjectName]["server"]> =>
server != null,
)
.map((server) => [server.port, server]),
).values(),
],
});