-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
106 lines (100 loc) · 4.04 KB
/
playwright.config.ts
File metadata and controls
106 lines (100 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { defineConfig, devices } from '@playwright/test'
import 'dotenv/config'
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: 'e2e',
/* Run tests in files in parallel */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Force single-worker execution for both local and CI runs.
*
* All web E2E tests share one seeded Clerk user (`test@test.com`) and a
* single PostgreSQL database. Running multiple workers in parallel causes
* cross-file data races — e.g. `qa-fixes.spec.ts`'s "Clear all completed"
* test calls the `clearCompleted` procedure which `deleteMany`s every
* completed todo for the user, cascading into `NodeAssignment` rows. If
* this races with `skill-tree.spec.ts`, it silently deletes the todos
* those tests just seeded.
*
* `fullyParallel: false` only guarantees serial execution WITHIN a file;
* different files can still run on separate workers. `workers: 1` is the
* only way to serialize across files when they share DB state.
*
* EXIT CRITERION: this halves CI throughput across the whole suite and
* should NOT be permanent. The clean fix is per-worker Clerk users so
* each worker owns its own Prisma user row, making `clearCompleted`
* naturally scoped to one worker's data. Tracked as a post-v1 follow-up
* task ("Post-v1: Restore parallel E2E workers via per-worker Clerk
* users") — once that lands, flip this back to `workers: undefined`. */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
// CI uses the "blob" reporter so each matrix shard (one per spec file in
// `.github/workflows/e2e.web.yml`) writes a `blob-report/` directory that
// a downstream `merge-reports` job combines into a single HTML report
// via `playwright merge-reports`. Locally, "list" gives terminal feedback
// (Playwright default) without producing artifacts. See
// https://playwright.dev/docs/test-sharding#merging-reports-from-multiple-shards.
process.env.CI ? ['blob'] : ['list'],
// Add Argos reporter.
//
// The matrix-shard workflow at `.github/workflows/e2e.web.yml` sets
// `ARGOS_PARALLEL` / `ARGOS_PARALLEL_NONCE` / `ARGOS_PARALLEL_TOTAL` so
// every shard's `argosScreenshot` calls collate into a single Argos
// build. Without parallel mode, the 4 spec files that take no
// screenshots would each create an empty Argos build that diffs as
// "2 removed" against the baseline. See
// https://argos-ci.com/docs/parallel-testing.
[
'@argos-ci/playwright/reporter',
{
// Upload to Argos on CI only.
uploadToArgos: !!process.env.CI,
token: process.env.ARGOS_TOKEN,
},
],
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:3011',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
/* Ensure test environment is set */
extraHTTPHeaders: {
'x-test-environment': 'true',
},
},
/* Configure projects for major browsers */
projects: [
// Setup project - runs authentication setup before all tests
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
},
{
name: 'web',
use: {
...devices['Desktop Chrome'],
// Use prepared auth state from setup
storageState: 'e2e/.auth/user.json',
},
testMatch: /^(?!.*electron).*\.spec\.ts$/,
dependencies: ['setup'], // Run setup project first
},
],
// One-time hooks
globalSetup: './e2e/global-setup.ts',
globalTeardown: './e2e/global-teardown.ts',
webServer: {
command: 'pnpm start',
url: 'http://localhost:3011',
reuseExistingServer: false,
timeout: 120 * 1000,
},
})