11import type { PlaywrightTestConfig } from '@playwright/test' ;
22import { devices } from '@playwright/test' ;
33
4- // todo: 支持legacy浏览器的测试
4+ const targetProject = process . argv . find ( ( arg ) => arg . startsWith ( '--project=' ) ) ?. split ( '=' ) [ 1 ] ;
5+ const PORTS = {
6+ chrome : 7080 ,
7+ firefox : 7081 ,
8+ webkit : 7082 ,
9+ edge : 7083 ,
10+ 'chromium-legacy' : 7084 ,
11+ } ;
12+ const port = PORTS [ targetProject ?? '' ] ?? PORTS . chrome ;
13+
514const config : PlaywrightTestConfig = {
615 testDir : './e2e/specs' ,
716 testMatch : '**/*.spec.ts' ,
@@ -12,13 +21,13 @@ const config: PlaywrightTestConfig = {
1221 forbidOnly : ! ! process . env . CI ,
1322 retries : 2 ,
1423 use : {
15- baseURL : ' http://localhost:7080' ,
24+ baseURL : ` http://localhost:${ port } ` ,
1625 headless : true ,
1726 } ,
1827 projects : [
1928 // Modern browsers
2029 {
21- name : 'chromium ' ,
30+ name : 'chrome ' ,
2231 use : devices [ 'Desktop Chrome' ] ,
2332 } ,
2433 {
@@ -29,6 +38,10 @@ const config: PlaywrightTestConfig = {
2938 name : 'webkit' ,
3039 use : devices [ 'Desktop Safari' ] ,
3140 } ,
41+ {
42+ name : 'edge' ,
43+ use : devices [ 'Desktop Edge' ] ,
44+ } ,
3245 // Legacy browsers (simulated)
3346 {
3447 name : 'chromium-legacy' ,
@@ -42,8 +55,8 @@ const config: PlaywrightTestConfig = {
4255 } ,
4356 ] ,
4457 webServer : {
45- command : ' npx http-server ./e2e/fixtures -p 7080' ,
46- port : 7080 ,
58+ command : ` npx http-server ./e2e/fixtures -p ${ port } ` ,
59+ port,
4760 reuseExistingServer : ! process . env . CI ,
4861 } ,
4962} ;
0 commit comments