|
a |
|
b/playwright.config.cjs |
|
|
1 |
// @ts-check |
|
|
2 |
const { defineConfig, devices } = require('@playwright/test'); |
|
|
3 |
|
|
|
4 |
/** |
|
|
5 |
* Read environment variables from file. |
|
|
6 |
* https://github.com/motdotla/dotenv |
|
|
7 |
*/ |
|
|
8 |
// require('dotenv').config(); |
|
|
9 |
|
|
|
10 |
/** |
|
|
11 |
* @see https://playwright.dev/docs/test-configuration |
|
|
12 |
*/ |
|
|
13 |
module.exports = defineConfig({ |
|
|
14 |
testDir: './tests', |
|
|
15 |
/* Run tests in files in parallel */ |
|
|
16 |
fullyParallel: true, |
|
|
17 |
/* Fail the build on CI if you accidentally left test.only in the source code. */ |
|
|
18 |
forbidOnly: !!process.env.CI, |
|
|
19 |
/* Retry on CI only */ |
|
|
20 |
retries: process.env.CI ? 2 : 0, |
|
|
21 |
/* Opt out of parallel tests on CI. */ |
|
|
22 |
workers: process.env.CI ? 1 : 1, |
|
|
23 |
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
|
|
24 |
reporter: 'html', |
|
|
25 |
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
|
|
26 |
use: { |
|
|
27 |
/* Base URL to use in actions like `await page.goto('/')`. */ |
|
|
28 |
// baseURL: 'http://127.0.0.1:3000', |
|
|
29 |
|
|
|
30 |
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
|
|
31 |
trace: 'on-first-retry', |
|
|
32 |
}, |
|
|
33 |
|
|
|
34 |
snapshotPathTemplate: './tests/snapshots/{testName}/{testName}-{projectName}{ext}', |
|
|
35 |
|
|
|
36 |
/* Configure projects for major browsers */ |
|
|
37 |
projects: [ |
|
|
38 |
{ |
|
|
39 |
name: 'chromium', |
|
|
40 |
use: { |
|
|
41 |
...devices['Desktop Chrome'], |
|
|
42 |
// set window size to 1280x720 |
|
|
43 |
viewport: { width: 1280, height: 720 }, |
|
|
44 |
headless: true, |
|
|
45 |
}, |
|
|
46 |
}, |
|
|
47 |
|
|
|
48 |
{ |
|
|
49 |
name: 'firefox', |
|
|
50 |
use: { |
|
|
51 |
...devices['Desktop Firefox'], |
|
|
52 |
// set window size to 1280x720 |
|
|
53 |
viewport: { width: 1280, height: 720 }, |
|
|
54 |
headless: true, |
|
|
55 |
}, |
|
|
56 |
}, |
|
|
57 |
|
|
|
58 |
{ |
|
|
59 |
name: 'webkit', |
|
|
60 |
use: { |
|
|
61 |
...devices['Desktop Safari'], |
|
|
62 |
// set window size to 1280x720 |
|
|
63 |
viewport: { width: 1280, height: 720 }, |
|
|
64 |
headless: true, |
|
|
65 |
}, |
|
|
66 |
}, |
|
|
67 |
], |
|
|
68 |
|
|
|
69 |
/* Run your local dev server before starting the tests */ |
|
|
70 |
webServer: { |
|
|
71 |
command: 'npm run preview', |
|
|
72 |
url: 'http://127.0.0.1:8088', |
|
|
73 |
reuseExistingServer: !process.env.CI, |
|
|
74 |
timeout: 20 * 1000, |
|
|
75 |
} |
|
|
76 |
}); |
|
|
77 |
|