loading up the forgejo repo on tangled to test page performance
1import {devices, type PlaywrightTestConfig} from '@playwright/test';
2
3const BASE_URL = process.env.GITEA_URL?.replace?.(/\/$/g, '') || 'http://localhost:3003';
4
5/**
6 * @see https://playwright.dev/docs/test-configuration
7 * @type {import('@playwright/test').PlaywrightTestConfig}
8 */
9export default {
10 testDir: './tests/e2e/',
11 testMatch: /.*\.test\.e2e\.ts/, // Match any .test.e2e.js files
12
13 // you can adjust this value locally to match your machine's power,
14 // or pass `--workers x` to playwright
15 workers: 1,
16
17 /* Maximum time one test can run for. */
18 timeout: 30 * 1000,
19
20 expect: {
21 /**
22 * Maximum time expect() should wait for the condition to be met.
23 * For example in `await expect(locator).toHaveText();`
24 */
25 timeout: 3000,
26 },
27
28 /* Fail the build on CI if you accidentally left test.only in the source code. */
29 forbidOnly: Boolean(process.env.CI),
30
31 /* Retry on CI only */
32 retries: process.env.CI ? 1 : 0,
33 /* fail fast */
34 maxFailures: process.env.CI ? 1 : 0,
35
36 /* Reporter to use. See https://playwright.dev/docs/test-reporters */
37 reporter: process.env.CI ? 'list' : [['list'], ['html', {outputFolder: 'tests/e2e/reports/', open: 'never'}]],
38
39 /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
40 use: {
41 headless: true, // set to false to debug
42
43 locale: 'en-US',
44
45 /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
46 actionTimeout: 3000,
47
48 /* Maximum time allowed for navigation, such as `page.goto()`. */
49 navigationTimeout: 10 * 1000,
50
51 /* Base URL to use in actions like `await page.goto('/')`. */
52 baseURL: BASE_URL,
53
54 /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
55 trace: 'on-first-retry',
56
57 screenshot: 'only-on-failure',
58 },
59
60 /* Configure projects for major browsers */
61 projects: [
62 {
63 name: 'chromium',
64
65 /* Project-specific settings. */
66 use: {
67 ...devices['Desktop Chrome'],
68 permissions: ['clipboard-read', 'clipboard-write'],
69 },
70 },
71
72 {
73 name: 'firefox',
74 use: {
75 ...devices['Desktop Firefox'],
76 },
77 },
78
79 {
80 name: 'webkit',
81 use: {
82 ...devices['Desktop Safari'],
83 },
84 },
85
86 /* Test against mobile viewports. */
87 {
88 name: 'Mobile Chrome',
89 use: {
90 ...devices['Pixel 5'],
91 permissions: ['clipboard-read', 'clipboard-write'],
92 },
93 },
94 {
95 name: 'Mobile Safari',
96 use: {
97 ...devices['iPhone 12'],
98 },
99 },
100 ],
101
102 /* Folder for test artifacts created during test execution such as screenshots, traces, etc. */
103 outputDir: 'tests/e2e/test-artifacts/',
104 /* Folder for explicit snapshots for visual testing */
105 snapshotDir: 'tests/e2e/test-snapshots/',
106 snapshotPathTemplate: '{snapshotDir}/snapshots/{testFilePath}/{projectName}_{arg}{ext}',
107} satisfies PlaywrightTestConfig;