|
1 |
| -import { defineConfig, devices } from '@playwright/test'; |
| 1 | +import type { PlaywrightTestConfig } from "@playwright/test"; |
| 2 | +import { devices } from "@playwright/test"; |
2 | 3 |
|
3 |
| -export default defineConfig({ |
4 |
| - testDir: './tests', |
| 4 | +/** |
| 5 | + * Read environment variables from file. |
| 6 | + * https://github.com/motdotla/dotenv |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * See https://playwright.dev/docs/test-configuration. |
| 11 | + */ |
| 12 | +const config: PlaywrightTestConfig = { |
| 13 | + testDir: "./src/tests", |
5 | 14 | /* Maximum time one test can run for. */
|
6 | 15 | timeout: 30 * 1000,
|
7 | 16 | expect: {
|
8 | 17 | /**
|
9 | 18 | * Maximum time expect() should wait for the condition to be met.
|
10 | 19 | * For example in `await expect(locator).toHaveText();`
|
11 | 20 | */
|
12 |
| - timeout: 5000, |
| 21 | + timeout: 5000 |
13 | 22 | },
|
14 | 23 | /* Run tests in files in parallel */
|
15 | 24 | fullyParallel: true,
|
16 | 25 | /* Fail the build on CI if you accidentally left test.only in the source code. */
|
17 |
| - forbidOnly: !!process.env.CI, |
| 26 | + forbidOnly: Boolean(process.env.CI), |
18 | 27 | /* Retry on CI only */
|
19 | 28 | retries: process.env.CI ? 2 : 0,
|
20 | 29 | /* Opt out of parallel tests on CI. */
|
21 |
| - workers: process.env.CI && 1, |
| 30 | + workers: process.env.CI ? 1 : undefined, |
22 | 31 | /* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
23 |
| - reporter: 'html', |
| 32 | + reporter: "html", |
24 | 33 | /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
25 | 34 | use: {
|
26 | 35 | /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
27 | 36 | actionTimeout: 0,
|
28 | 37 | /* Base URL to use in actions like `await page.goto('/')`. */
|
29 |
| - baseURL: 'http://localhost:3000', |
| 38 | + baseURL: "http://localhost:3000", |
30 | 39 |
|
31 | 40 | /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
32 |
| - trace: 'on-first-retry', |
| 41 | + trace: "on-first-retry", |
| 42 | + |
| 43 | + viewport: { width: 1920, height: 1080 } |
33 | 44 | },
|
34 | 45 |
|
35 | 46 | /* Configure projects for major browsers */
|
36 | 47 | projects: [
|
37 | 48 | {
|
38 |
| - name: 'chromium', |
39 |
| - use: { ...devices['Desktop Chrome'] }, |
| 49 | + name: "chromium", |
| 50 | + use: { |
| 51 | + ...devices["Desktop Chrome"] |
| 52 | + } |
40 | 53 | },
|
41 | 54 |
|
42 | 55 | {
|
43 |
| - name: 'firefox', |
44 |
| - use: { ...devices['Desktop Firefox'] }, |
| 56 | + name: "firefox", |
| 57 | + use: { |
| 58 | + ...devices["Desktop Firefox"] |
| 59 | + } |
45 | 60 | },
|
46 | 61 |
|
47 | 62 | {
|
48 |
| - name: 'webkit', |
49 |
| - use: { ...devices['Desktop Safari'] }, |
50 |
| - }, |
| 63 | + name: "webkit", |
| 64 | + use: { |
| 65 | + ...devices["Desktop Safari"] |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + /* Test against mobile viewports. */ |
| 70 | + // { |
| 71 | + // name: 'Mobile Chrome', |
| 72 | + // use: { |
| 73 | + // ...devices['Pixel 5'], |
| 74 | + // }, |
| 75 | + // }, |
| 76 | + // { |
| 77 | + // name: 'Mobile Safari', |
| 78 | + // use: { |
| 79 | + // ...devices['iPhone 12'], |
| 80 | + // }, |
| 81 | + // }, |
| 82 | + |
| 83 | + /* Test against branded browsers. */ |
| 84 | + // { |
| 85 | + // name: 'Microsoft Edge', |
| 86 | + // use: { |
| 87 | + // channel: 'msedge', |
| 88 | + // }, |
| 89 | + // }, |
| 90 | + // { |
| 91 | + // name: 'Google Chrome', |
| 92 | + // use: { |
| 93 | + // channel: 'chrome', |
| 94 | + // }, |
| 95 | + // }, |
51 | 96 | ],
|
52 | 97 |
|
53 | 98 | /* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
54 |
| - outputDir: 'test-results/', |
| 99 | + outputDir: "test-results/", |
55 | 100 |
|
56 | 101 | /* Run your local dev server before starting the tests */
|
57 | 102 | webServer: {
|
58 |
| - command: 'npm run start', |
59 |
| - port: 3000, |
60 |
| - }, |
61 |
| -}); |
| 103 | + reuseExistingServer: true, |
| 104 | + command: "npm run dev", |
| 105 | + port: 3000 |
| 106 | + } |
| 107 | +}; |
| 108 | + |
| 109 | +export default config; |
0 commit comments