Skip to content

Commit a8d7723

Browse files
committed
chore: 添加 Playwright 配置文件,设置测试目录和并行执行选项
1 parent 7548c0e commit a8d7723

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

playwright.config.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* @see https://playwright.dev/docs/test-configuration
5+
*/
6+
export default defineConfig({
7+
testDir: './test',
8+
/* Run tests in files in parallel */
9+
fullyParallel: true,
10+
/* Fail the build on CI if you accidentally left test.only in the source code. */
11+
forbidOnly: !!process.env.CI,
12+
/* Retry on CI only */
13+
retries: process.env.CI ? 2 : 0,
14+
/* Opt out of parallel tests on CI. */
15+
workers: process.env.CI ? 1 : undefined,
16+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
17+
// reporter: 'html',
18+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
19+
use: {
20+
/* Base URL to use in actions like `await page.goto('/')`. */
21+
// baseURL: 'http://127.0.0.1:3000',
22+
23+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
24+
trace: 'on-first-retry',
25+
},
26+
27+
/* Configure projects for major browsers */
28+
projects: [
29+
{
30+
name: 'chromium',
31+
use: { ...devices['Desktop Chrome'] },
32+
},
33+
34+
// {
35+
// name: 'firefox',
36+
// use: { ...devices['Desktop Firefox'] },
37+
// },
38+
39+
// {
40+
// name: 'webkit',
41+
// use: { ...devices['Desktop Safari'] },
42+
// },
43+
44+
/* Test against mobile viewports. */
45+
// {
46+
// name: 'Mobile Chrome',
47+
// use: { ...devices['Pixel 5'] },
48+
// },
49+
// {
50+
// name: 'Mobile Safari',
51+
// use: { ...devices['iPhone 12'] },
52+
// },
53+
54+
/* Test against branded browsers. */
55+
// {
56+
// name: 'Microsoft Edge',
57+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
58+
// },
59+
// {
60+
// name: 'Google Chrome',
61+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
62+
// },
63+
],
64+
65+
/* Run your local dev server before starting the tests */
66+
// webServer: {
67+
// command: 'npm run start',
68+
// url: 'http://127.0.0.1:3000',
69+
// reuseExistingServer: !process.env.CI,
70+
// },
71+
});

0 commit comments

Comments
 (0)