-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplaywright.config.js
More file actions
74 lines (60 loc) · 2.51 KB
/
playwright.config.js
File metadata and controls
74 lines (60 loc) · 2.51 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
/**
* Playwright E2E test configuration for Gratis AI Agent.
*
* Tests run against a wp-env WordPress environment.
* Start the environment with `npm run wp-env:start` before running tests.
*
* @see https://playwright.dev/docs/test-configuration
*/
const { defineConfig, devices } = require( '@playwright/test' );
const ciWorkers = Number.parseInt( process.env.PLAYWRIGHT_WORKERS || '2', 10 );
/** @param {number} n @returns {number} */
function getWorkerCount( n ) {
return Number.isFinite( n ) && n > 0 ? n : 2;
}
module.exports = defineConfig( {
testDir: './tests/e2e',
testMatch: '**/*.spec.js',
/* Maximum time one test can run for.
* 90 s gives loginToWordPress (60 s redirect wait) + goToAgentPage
* (30 s SPA mount wait) enough headroom on CI runners. The 60 s
* timeout was too tight — login + navigation alone consumed the full
* budget, leaving no time for assertions. */
timeout: 90_000,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !! process.env.CI,
/* Retry on CI only — 2 retries to handle CI flakiness from slow
* Docker-based wp-env on GitHub Actions runners. */
retries: process.env.CI ? 2 : 0,
/* Worker count on CI is tunable via PLAYWRIGHT_WORKERS env var.
* Both WP 6.9 and trunk use 2 workers (set in e2e.yml) to avoid
* overloading the wp-env environment — more workers cause resource
* contention that manifests as login and SPA-render timeouts on CI
* runners. The suite is sharded (3 shards per WP version) so 2 workers
* per shard is sufficient to complete within the 45-min shard timeout. */
workers: process.env.CI ? getWorkerCount( ciWorkers ) : undefined,
/* Reporter to use.
* CI uses list + github + html: list outputs per-test names and errors
* to the log (the github reporter only emits a compact progress line
* and annotations on completion — if the job times out, no annotations
* are created and errors are invisible). */
reporter: process.env.CI
? [ [ 'list' ], [ 'github' ], [ 'html', { open: 'never' } ] ]
: [ [ 'list' ], [ 'html', { open: 'on-failure' } ] ],
use: {
/* wp-env default URL — must match .wp-env.json "port" (8890). */
baseURL: process.env.WP_BASE_URL || 'http://localhost:8890',
/* Collect trace when retrying the failed test. */
trace: 'on-first-retry',
/* Take screenshot on failure. */
screenshot: 'only-on-failure',
/* Video on first retry. */
video: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices[ 'Desktop Chrome' ] },
},
],
} );