|
1 |
| -import { defineConfig, devices } from '@playwright/test' |
| 1 | +import { defineConfig } from '@playwright/test' |
2 | 2 |
|
3 |
| -/** |
4 |
| - * Read environment variables from file. |
5 |
| - * https://github.com/motdotla/dotenv |
6 |
| - */ |
7 |
| -// require('dotenv').config(); |
| 3 | +const baseUrl = process.env.BASE_URL || 'http://127.0.0.1:8888' |
| 4 | +const command = process.env.COMMAND || 'pnpm dev:full' |
| 5 | +const isCi = !!process.env.CI |
8 | 6 |
|
9 |
| -/** |
10 |
| - * See https://playwright.dev/docs/test-configuration. |
11 |
| - */ |
12 | 7 | export default defineConfig({
|
13 |
| - testDir: './test/e2e', |
14 |
| - /* Run tests in files in parallel */ |
| 8 | + forbidOnly: !!isCi, |
15 | 9 | fullyParallel: true,
|
16 |
| - /* Fail the build on CI if you accidentally left test.only in the source code. */ |
17 |
| - forbidOnly: !!process.env.CI, |
18 |
| - /* Retry on CI only */ |
19 |
| - retries: process.env.CI ? 2 : 0, |
20 |
| - /* Opt out of parallel tests on CI. */ |
21 |
| - workers: process.env.CI ? 1 : undefined, |
22 |
| - /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
23 |
| - reporter: 'html', |
24 |
| - /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 10 | + retries: isCi ? 2 : 0, |
| 11 | + testDir: './test/e2e', |
25 | 12 | use: {
|
26 |
| - /* Base URL to use in actions like `await page.goto('/')`. */ |
27 |
| - baseURL: process.env.BASE_URL || 'http://127.0.0.1:8888', |
28 |
| - |
| 13 | + baseURL: baseUrl, |
29 | 14 | testIdAttribute: 'data-test-id',
|
30 |
| - |
31 |
| - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
32 | 15 | trace: 'on-first-retry',
|
33 | 16 | video: 'retain-on-failure',
|
34 | 17 | },
|
35 |
| - |
36 |
| - /* Configure projects for major browsers */ |
37 |
| - projects: [ |
38 |
| - { |
39 |
| - name: 'chromium', |
40 |
| - use: { ...devices['Desktop Chrome'] }, |
41 |
| - }, |
42 |
| - |
43 |
| - { |
44 |
| - name: 'firefox', |
45 |
| - use: { ...devices['Desktop Firefox'] }, |
46 |
| - }, |
47 |
| - |
48 |
| - { |
49 |
| - name: 'webkit', |
50 |
| - use: { ...devices['Desktop Safari'] }, |
51 |
| - }, |
52 |
| - |
53 |
| - /* Test against mobile viewports. */ |
54 |
| - // { |
55 |
| - // name: 'Mobile Chrome', |
56 |
| - // use: { ...devices['Pixel 5'] }, |
57 |
| - // }, |
58 |
| - // { |
59 |
| - // name: 'Mobile Safari', |
60 |
| - // use: { ...devices['iPhone 12'] }, |
61 |
| - // }, |
62 |
| - |
63 |
| - /* Test against branded browsers. */ |
64 |
| - // { |
65 |
| - // name: 'Microsoft Edge', |
66 |
| - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, |
67 |
| - // }, |
68 |
| - // { |
69 |
| - // name: 'Google Chrome', |
70 |
| - // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, |
71 |
| - // }, |
72 |
| - ], |
73 |
| - |
74 |
| - /* Run your local dev server before starting the tests */ |
75 | 18 | webServer: {
|
76 |
| - command: 'pnpm dev:full', |
77 |
| - url: process.env.BASE_URL || 'http://127.0.0.1:8888', |
78 |
| - reuseExistingServer: !process.env.CI, |
| 19 | + command, |
| 20 | + reuseExistingServer: !isCi, |
| 21 | + url: baseUrl, |
79 | 22 | },
|
80 | 23 | })
|
0 commit comments