Skip to content

Commit 09892dd

Browse files
committed
ci: improve e2e tests
1 parent 284d508 commit 09892dd

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

.github/workflows/test-on-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
test:
1919
uses: ./.github/workflows/reusable-test.yml
2020
with:
21-
use-matrix: false
21+
use-matrix: true

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "enum-plus",
3-
"version": "3.0.0-alpha.2",
3+
"version": "3.0.0-alpha.1",
44
"description": "A drop-in replacement for native enum. Like native enum but much better!",
55
"keywords": [
66
"enum",
@@ -107,6 +107,11 @@
107107
"task:run-e2e": "playwright test",
108108
"task:run-e2e-debug": "playwright test --debug",
109109
"task:run-e2e-ui": "playwright test --ui",
110+
"task:run-e2e:chrome": "playwright test --project=chrome",
111+
"task:run-e2e:chromium-legacy": "playwright test --project=chromium-legacy",
112+
"task:run-e2e:edge": "playwright test --project=edge",
113+
"task:run-e2e:firefox": "playwright test --project=firefox",
114+
"task:run-e2e:webkit": "playwright test --project=webkit",
110115
"test": "npm run task:jest",
111116
"test-lib": "run-s ts2lib task:jest:lib",
112117
"ts2lib": "tsc -p tsconfig.lib.json"

playwright.config.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import type { PlaywrightTestConfig } from '@playwright/test';
22
import { 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+
514
const 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

Comments
 (0)