Debian Codegraph @

tests/config/playwright.config.ts

raw
1 import { defineConfig, devices } from '@playwright/test';
2
3 /**
4 * Read environment variables from file.
5 * https://github.com/motdotla/dotenv
6 */
7 // require('dotenv').config();
8
9 const baseURL = 'http://localhost:8274';
10
11 /**
12 * See https://playwright.dev/docs/test-configuration.
13 */
14 export default defineConfig({
15 /* Directory containing the test files */
16 testDir: '../functional',
17 /* Folder for test artifacts: screenshots, videos, ... */
18 outputDir: '../results',
19 /* Timeout individual tests after 5 seconds */
20 timeout: 10_000,
21 /* Run tests in files in parallel */
22 fullyParallel: true,
23 /* Fail the build on CI if you accidentally left test.only in the source code. */
24 forbidOnly: !!process.env.CI,
25 /* Retry on CI only */
26 retries: process.env.CI ? 1 : 0,
27 /* Limit parallel workers on CI, use default locally. */
28 workers: process.env.CI ? 1 : undefined,
29 // Limit the number of failures on CI to save resources
30 maxFailures: process.env.CI ? 10 : undefined,
31 /* Reporter to use. See https://playwright.dev/docs/test-reporters */
32 reporter: process.env.CI ? [
33 ['dot'],
34 ['github'],
35 ['blob', { outputDir: '../reports/blobs' }],
36 ] : [
37 ['list'],
38 ['html', { outputFolder: '../reports/html', open: 'on-failure' }],
39 ['json', { outputFile: '../reports/json/report.json' }],
40 ],
41
42 expect: {
43 /* Timeout async expect matchers after 2 seconds */
44 timeout: 3_000,
45 },
46
47 /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
48 use: {
49 /* Base URL to use in actions like `await page.goto('/')`. */
50 baseURL,
51 /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
52 trace: 'on-first-retry',
53 /* Capture screenshot after each test failure. */
54 screenshot: 'only-on-failure',
55 /* Capture video if failed tests. */
56 video: 'retain-on-failure',
57 },
58
59 /* Configure projects for major browsers */
60 projects: [
61 { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
62 { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
63 { name: 'webkit', use: { ...devices['Desktop Safari'] } },
64 ],
65
66 /* Run your local dev server before starting the tests */
67 webServer: {
68 url: baseURL,
69 command: 'npm run test:e2e:start',
70 reuseExistingServer: !process.env.CI,
71 },
72 });