@matware/e2e-runner 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +21 -0
- package/.claude-plugin/plugin.json +9 -0
- package/.mcp.json +9 -0
- package/.opencode/commands/create-test.md +63 -0
- package/.opencode/commands/run.md +50 -0
- package/.opencode/commands/verify-issue.md +62 -0
- package/.opencode/skills/e2e-testing/SKILL.md +181 -0
- package/.opencode/skills/e2e-testing/references/action-types.md +143 -0
- package/.opencode/skills/e2e-testing/references/auth-strategies.md +91 -0
- package/.opencode/skills/e2e-testing/references/graphql.md +59 -0
- package/.opencode/skills/e2e-testing/references/issue-verification.md +59 -0
- package/.opencode/skills/e2e-testing/references/multi-pool.md +60 -0
- package/.opencode/skills/e2e-testing/references/network-debugging.md +62 -0
- package/.opencode/skills/e2e-testing/references/test-json-format.md +163 -0
- package/.opencode/skills/e2e-testing/references/troubleshooting.md +224 -0
- package/.opencode/skills/e2e-testing/references/variables.md +41 -0
- package/.opencode/skills/e2e-testing/references/visual-verification.md +89 -0
- package/OPENCODE.md +166 -0
- package/README.md +990 -296
- package/agents/test-analyzer.md +81 -0
- package/agents/test-creator.md +155 -0
- package/agents/test-improver.md +177 -0
- package/bin/cli.js +602 -22
- package/commands/create-test.md +65 -0
- package/commands/run.md +49 -0
- package/commands/verify-issue.md +63 -0
- package/opencode.json +11 -0
- package/package.json +15 -2
- package/scripts/setup-opencode.sh +113 -0
- package/skills/e2e-testing/SKILL.md +173 -0
- package/skills/e2e-testing/references/action-types.md +143 -0
- package/skills/e2e-testing/references/auth-strategies.md +91 -0
- package/skills/e2e-testing/references/graphql.md +59 -0
- package/skills/e2e-testing/references/issue-verification.md +59 -0
- package/skills/e2e-testing/references/multi-pool.md +60 -0
- package/skills/e2e-testing/references/network-debugging.md +62 -0
- package/skills/e2e-testing/references/test-json-format.md +163 -0
- package/skills/e2e-testing/references/troubleshooting.md +224 -0
- package/skills/e2e-testing/references/variables.md +41 -0
- package/skills/e2e-testing/references/visual-verification.md +89 -0
- package/src/actions.js +597 -20
- package/src/ai-generate.js +142 -12
- package/src/config.js +171 -0
- package/src/dashboard.js +299 -17
- package/src/db.js +335 -13
- package/src/index.js +15 -8
- package/src/learner-markdown.js +177 -0
- package/src/learner-neo4j.js +255 -0
- package/src/learner-sqlite.js +658 -0
- package/src/learner.js +418 -0
- package/src/mcp-tools.js +1558 -50
- package/src/module-resolver.js +310 -0
- package/src/narrate.js +262 -0
- package/src/neo4j-pool.js +124 -0
- package/src/pool-manager.js +223 -0
- package/src/reporter.js +117 -3
- package/src/runner.js +274 -71
- package/src/sync/auth.js +354 -0
- package/src/sync/client.js +572 -0
- package/src/sync/hub-routes.js +816 -0
- package/src/sync/index.js +68 -0
- package/src/sync/middleware.js +347 -0
- package/src/sync/queue.js +209 -0
- package/src/sync/schema.js +540 -0
- package/src/verify.js +14 -9
- package/src/watch.js +384 -0
- package/templates/build-dashboard.js +69 -0
- package/templates/dashboard/js/api.js +60 -0
- package/templates/dashboard/js/init.js +13 -0
- package/templates/dashboard/js/keyboard.js +46 -0
- package/templates/dashboard/js/state.js +40 -0
- package/templates/dashboard/js/toast.js +41 -0
- package/templates/dashboard/js/utils.js +196 -0
- package/templates/dashboard/js/view-live.js +143 -0
- package/templates/dashboard/js/view-runs.js +572 -0
- package/templates/dashboard/js/view-tests.js +294 -0
- package/templates/dashboard/js/view-watch.js +242 -0
- package/templates/dashboard/js/websocket.js +110 -0
- package/templates/dashboard/styles/base.css +69 -0
- package/templates/dashboard/styles/components.css +110 -0
- package/templates/dashboard/styles/view-live.css +74 -0
- package/templates/dashboard/styles/view-runs.css +207 -0
- package/templates/dashboard/styles/view-tests.css +96 -0
- package/templates/dashboard/styles/view-watch.css +53 -0
- package/templates/dashboard/template.html +267 -0
- package/templates/dashboard.html +2171 -530
- package/templates/docker-compose-neo4j.yml +19 -0
- package/templates/e2e.config.js +3 -0
- package/templates/sample-test.json +0 -8
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Authentication Strategies
|
|
2
|
+
|
|
3
|
+
Tests can authenticate using multiple strategies depending on the app's auth mechanism.
|
|
4
|
+
|
|
5
|
+
## 1. UI Login (universal)
|
|
6
|
+
|
|
7
|
+
Fill the login form in `beforeEach`. Works with any auth system — the browser stores cookies/tokens automatically.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{ "hooks": { "beforeEach": [
|
|
11
|
+
{ "type": "goto", "value": "/login" },
|
|
12
|
+
{ "type": "type", "selector": "#email", "value": "test@example.com" },
|
|
13
|
+
{ "type": "type", "selector": "#password", "value": "secret" },
|
|
14
|
+
{ "type": "click", "text": "Sign In" },
|
|
15
|
+
{ "type": "wait", "selector": ".dashboard" }
|
|
16
|
+
]}}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 2. JWT Injection (SPAs)
|
|
20
|
+
|
|
21
|
+
Skip the login form by injecting a token into `localStorage` or `sessionStorage`:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{ "type": "set_storage", "value": "accessToken=eyJhbG..." }
|
|
25
|
+
{ "type": "set_storage", "value": "token=eyJhbG...", "selector": "session" }
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 3. Config-Level Token
|
|
29
|
+
|
|
30
|
+
Set `authToken` + `authStorageKey` in config, env vars (`AUTH_TOKEN`, `AUTH_STORAGE_KEY`), or CLI flags (`--auth-token`, `--auth-storage-key`). Used by `e2e_capture` and `e2e_issue --verify`.
|
|
31
|
+
|
|
32
|
+
## 4. Cookie-Based (server-rendered)
|
|
33
|
+
|
|
34
|
+
Set cookies via `evaluate`:
|
|
35
|
+
```json
|
|
36
|
+
{ "type": "evaluate", "value": "document.cookie = 'session_id=abc123; path=/; SameSite=Lax'" }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 5. API Headers
|
|
40
|
+
|
|
41
|
+
Override `fetch` to inject Authorization headers (useful for `--test-type api`):
|
|
42
|
+
```json
|
|
43
|
+
{ "type": "evaluate", "value": "const orig = window.fetch; window.fetch = (url, opts = {}) => { opts.headers = { ...opts.headers, 'Authorization': 'Bearer eyJhbG...' }; return orig(url, opts); }" }
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 6. OAuth/SSO
|
|
47
|
+
|
|
48
|
+
Use a test-environment bypass endpoint, pre-authenticated token injection, or CI-obtained session cookie. External OAuth providers (Google, GitHub, Okta) can't be automated directly.
|
|
49
|
+
|
|
50
|
+
## Auth Auto-Login
|
|
51
|
+
|
|
52
|
+
Automatically fetch an auth token from a login API endpoint before tests run. Avoids repeating login flows in every test.
|
|
53
|
+
|
|
54
|
+
### Config fields
|
|
55
|
+
|
|
56
|
+
| Field | Description | Env / CLI |
|
|
57
|
+
|-------|-------------|-----------|
|
|
58
|
+
| `authLoginEndpoint` | Full URL to POST credentials to | `AUTH_LOGIN_ENDPOINT` / `--auth-login-endpoint` |
|
|
59
|
+
| `authCredentials` | Object with login credentials (config file only — never in env vars) | — |
|
|
60
|
+
| `authTokenPath` | Dot-path to extract token from response JSON (default: `'token'`) | `AUTH_TOKEN_PATH` / `--auth-token-path` |
|
|
61
|
+
|
|
62
|
+
### Flow
|
|
63
|
+
|
|
64
|
+
1. Before workers start, if `authLoginEndpoint` is set and `authToken` is NOT already set, `fetchAuthToken()` POSTs `authCredentials` as JSON.
|
|
65
|
+
2. The token is extracted from the response using `authTokenPath` (supports dot notation, e.g. `'data.access_token'`).
|
|
66
|
+
3. The extracted token is stored in `config.authToken`.
|
|
67
|
+
4. Each test worker navigates to `baseUrl` and injects `localStorage[authStorageKey] = authToken` before `beforeEach` hooks run.
|
|
68
|
+
|
|
69
|
+
### Example config
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
export default {
|
|
73
|
+
authLoginEndpoint: 'https://api.example.com/auth/login',
|
|
74
|
+
authCredentials: { email: 'test@example.com', password: 'secret123' },
|
|
75
|
+
authTokenPath: 'data.access_token',
|
|
76
|
+
authStorageKey: 'accessToken',
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If `authToken` is already set (via config, env var, or CLI), the auto-login step is skipped.
|
|
81
|
+
|
|
82
|
+
## Clearing State
|
|
83
|
+
|
|
84
|
+
Each test runs in a fresh browser context (auto-clean). Use `clear_cookies` to explicitly clear cookies + localStorage + sessionStorage mid-test.
|
|
85
|
+
|
|
86
|
+
## Reusable Auth Modules
|
|
87
|
+
|
|
88
|
+
Create `e2e/modules/login.json` or `e2e/modules/auth-token.json` and reference via:
|
|
89
|
+
```json
|
|
90
|
+
{ "$use": "login", "params": { "email": "...", "password": "..." } }
|
|
91
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# GraphQL Action Reference
|
|
2
|
+
|
|
3
|
+
The `gql` action executes GraphQL queries and mutations via browser `fetch`, with automatic auth token injection from `localStorage`. It also installs a `window.__e2eGql(query, vars)` helper for use in subsequent `evaluate` actions.
|
|
4
|
+
|
|
5
|
+
## Action Fields
|
|
6
|
+
|
|
7
|
+
| Action | Fields | Behavior |
|
|
8
|
+
|--------|--------|----------|
|
|
9
|
+
| `gql` | `value` (query string, required), `text` (variables JSON, optional), `selector` (assertion JS expression, optional) | Sends a GraphQL request to the configured endpoint. Reads auth token from localStorage. Throws on GraphQL errors. Returns `{ value: response.data }`. Stores full response on `window.__e2eLastGql`. |
|
|
10
|
+
|
|
11
|
+
## Config Fields
|
|
12
|
+
|
|
13
|
+
| Field | Default | Env Var | CLI Flag |
|
|
14
|
+
|-------|---------|---------|----------|
|
|
15
|
+
| `gqlEndpoint` | `/api/graphql` | `GQL_ENDPOINT` | `--gql-endpoint` |
|
|
16
|
+
| `gqlAuthHeader` | `Authorization` | `GQL_AUTH_HEADER` | `--gql-auth-header` |
|
|
17
|
+
| `gqlAuthKey` | `accessToken` | `GQL_AUTH_KEY` | `--gql-auth-key` |
|
|
18
|
+
| `gqlAuthPrefix` | `Bearer ` | `GQL_AUTH_PREFIX` | `--gql-auth-prefix` |
|
|
19
|
+
|
|
20
|
+
The endpoint path is appended to `location.origin`. The auth token is read from `localStorage[gqlAuthKey]` and sent as `gqlAuthHeader: gqlAuthPrefix + token`.
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### Basic query
|
|
25
|
+
```json
|
|
26
|
+
{ "type": "gql", "value": "{ users { id name } }" }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### With variables
|
|
30
|
+
```json
|
|
31
|
+
{ "type": "gql", "value": "query($id: ID, $orgId: ID) { orders(userId: $id, orgId: $orgId) { orderId status } }", "text": "{\"id\": \"abc-123\", \"orgId\": \"org-456\"}" }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### With inline assertion (selector field)
|
|
35
|
+
```json
|
|
36
|
+
// selector is a JS expression where `r` is the full GraphQL response
|
|
37
|
+
{ "type": "gql", "value": "{ pendingOrders(userId: \"abc-123\") { status } }", "selector": "r.data.pendingOrders.some(o => o.status === 'CANCELLED') ? 'FAIL: cancelled order found in pending list' : 'OK: all pending'" }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Using the installed helper in evaluate
|
|
41
|
+
```json
|
|
42
|
+
// After any gql action runs, window.__e2eGql(query, vars) is available
|
|
43
|
+
{ "type": "gql", "value": "{ __typename }" }
|
|
44
|
+
{ "type": "evaluate", "value": "(async () => { const r = await window.__e2eGql('query { orders(status: [PROCESSING]) { orderId } }'); for (const o of r.data.orders) await window.__e2eGql('mutation($id: ID, $input: OrderInput) { updateOrder(orderId: $id, input: $input) { orderId } }', { id: o.orderId, input: { status: 'COMPLETED' } }); return 'Updated ' + r.data.orders.length; })()" }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Custom Auth Header Config
|
|
48
|
+
|
|
49
|
+
If your API uses a non-standard auth header (e.g., `x-api-key` instead of `Authorization`):
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// e2e.config.js
|
|
53
|
+
export default {
|
|
54
|
+
gqlEndpoint: '/api/graphql',
|
|
55
|
+
gqlAuthHeader: 'x-api-key', // custom header name
|
|
56
|
+
gqlAuthKey: 'apiToken', // localStorage key to read from
|
|
57
|
+
gqlAuthPrefix: '', // no 'Bearer ' prefix — raw token
|
|
58
|
+
};
|
|
59
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Issue-to-Test Verification Reference
|
|
2
|
+
|
|
3
|
+
Turns bug reports and feature requests into executable E2E tests.
|
|
4
|
+
|
|
5
|
+
## Supported Providers
|
|
6
|
+
|
|
7
|
+
- **GitHub** (`github.com`) — requires `gh` CLI (`gh auth login`)
|
|
8
|
+
- **GitLab** (including self-hosted) — requires `glab` CLI (`glab auth login`)
|
|
9
|
+
|
|
10
|
+
Auto-detected from URL. All external commands use `execFileSync` (no shell injection).
|
|
11
|
+
|
|
12
|
+
## Two AI Modes
|
|
13
|
+
|
|
14
|
+
### 1. Prompt Mode (default, no API key)
|
|
15
|
+
|
|
16
|
+
`e2e_issue` MCP tool returns issue details + a structured prompt. Claude Code then uses `e2e_create_test` to create tests and `e2e_run` to execute them.
|
|
17
|
+
|
|
18
|
+
### 2. Verify Mode (requires `ANTHROPIC_API_KEY`)
|
|
19
|
+
|
|
20
|
+
Calls Claude API directly to generate tests, runs them, and reports whether the bug is confirmed or not reproducible.
|
|
21
|
+
|
|
22
|
+
## Config Fields
|
|
23
|
+
|
|
24
|
+
| Field | Description | Env Var |
|
|
25
|
+
|-------|-------------|---------|
|
|
26
|
+
| `anthropicApiKey` | Required for verify/generate mode | `ANTHROPIC_API_KEY` |
|
|
27
|
+
| `anthropicModel` | Claude model for generation (default: `claude-sonnet-4-5-20250929`) | `ANTHROPIC_MODEL` |
|
|
28
|
+
|
|
29
|
+
## Bug Verification Logic
|
|
30
|
+
|
|
31
|
+
Generated tests assert **correct** behavior:
|
|
32
|
+
- **Test failure** = bug confirmed (expected behavior doesn't match reality)
|
|
33
|
+
- **All tests pass** = not reproducible
|
|
34
|
+
|
|
35
|
+
## Test Categories (`testType`)
|
|
36
|
+
|
|
37
|
+
The `--test-type` CLI flag (or `testType` MCP parameter) controls what kind of tests the AI generates:
|
|
38
|
+
|
|
39
|
+
- **`e2e`** (default): UI-driven tests — navigate pages, interact with elements (click, type, select), verify visible state. Never uses `evaluate` for API calls.
|
|
40
|
+
- **`api`**: Backend API tests — use `evaluate` actions for GraphQL/REST calls, assert response shapes and values. No UI interaction needed.
|
|
41
|
+
|
|
42
|
+
CLI: `e2e-runner issue <url> --generate --test-type api`
|
|
43
|
+
MCP: `e2e_issue({ url, testType: "api" })`
|
|
44
|
+
|
|
45
|
+
## GitLab Limitations
|
|
46
|
+
|
|
47
|
+
- Requires `glab` CLI installed and authenticated (`glab auth login`)
|
|
48
|
+
- Self-hosted GitLab instances supported via URL detection
|
|
49
|
+
- Verify mode works with GitLab issues but does NOT post comments back to the issue
|
|
50
|
+
- Private repos require `glab` to be authenticated with appropriate access
|
|
51
|
+
- The `authToken`/`authStorageKey` params on `e2e_issue` are for the **app under test**, not for GitLab API auth
|
|
52
|
+
|
|
53
|
+
## Key Files
|
|
54
|
+
|
|
55
|
+
| File | Purpose |
|
|
56
|
+
|------|---------|
|
|
57
|
+
| `src/issues.js` | GitHub/GitLab provider drivers |
|
|
58
|
+
| `src/ai-generate.js` | AI prompt builder + Claude API |
|
|
59
|
+
| `src/verify.js` | Verification orchestrator: fetch + generate + run |
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Multi-Pool Support
|
|
2
|
+
|
|
3
|
+
A single runner can distribute tests across multiple Chrome pools on different machines. `src/pool-manager.js` abstracts pool selection behind a **least-pressure** strategy. `poolUrl` (singular string) remains fully backwards compatible.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
// Single pool (unchanged)
|
|
9
|
+
export default { poolUrl: 'ws://localhost:3333' };
|
|
10
|
+
|
|
11
|
+
// Multi-pool — tests distribute across all pools
|
|
12
|
+
export default {
|
|
13
|
+
poolUrls: ['ws://machine1:3333', 'ws://machine2:3333'],
|
|
14
|
+
concurrency: 15,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// CI environment profile
|
|
18
|
+
export default {
|
|
19
|
+
poolUrl: 'ws://localhost:3333',
|
|
20
|
+
environments: {
|
|
21
|
+
ci: { poolUrls: ['ws://ci-chrome1:3333', 'ws://ci-chrome2:3333'], concurrency: 10 },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**CLI:** `e2e-runner run --all --pool-urls ws://m1:3333,ws://m2:3333`
|
|
27
|
+
**Env:** `CHROME_POOL_URLS=ws://m1:3333,ws://m2:3333` (comma-separated)
|
|
28
|
+
|
|
29
|
+
## Pool Selection Algorithm (`selectPool`)
|
|
30
|
+
|
|
31
|
+
1. Query all pools' `/pressure` in parallel
|
|
32
|
+
2. Filter to reachable pools with `running < maxConcurrent`
|
|
33
|
+
3. Sort by: lowest `running/maxConcurrent` → fewest queued → most free slots
|
|
34
|
+
4. Return best candidate URL
|
|
35
|
+
5. If all full, poll every 2s up to 60s, then pick least-pressured anyway
|
|
36
|
+
|
|
37
|
+
## Pool-Aware Queue
|
|
38
|
+
|
|
39
|
+
Before opening a browser connection, each worker checks the pool's `/pressure` endpoint. If the pool is at capacity, the worker waits (polling every 2s, up to 60s) for a free slot instead of piling requests into browserless's internal queue. This prevents memory pressure and SIGKILL of Chrome processes under heavy load.
|
|
40
|
+
|
|
41
|
+
## Failure Resilience
|
|
42
|
+
|
|
43
|
+
Dead pools are excluded from selection. `waitForAnyPool` succeeds if any pool responds. Failed connections trigger re-selection on the next worker.
|
|
44
|
+
|
|
45
|
+
## Config Normalization in `loadConfig()`
|
|
46
|
+
|
|
47
|
+
- If `poolUrls` array is set → `config._poolUrls = poolUrls`, `config.poolUrl = poolUrls[0]`
|
|
48
|
+
- Else → `config._poolUrls = [config.poolUrl]`
|
|
49
|
+
- `config.poolUrls` is deleted after normalization (use `config._poolUrls` internally)
|
|
50
|
+
|
|
51
|
+
## Key Functions (`src/pool-manager.js`)
|
|
52
|
+
|
|
53
|
+
| Function | Purpose |
|
|
54
|
+
|----------|---------|
|
|
55
|
+
| `getPoolUrls(config)` | Returns `config._poolUrls` (always an array) |
|
|
56
|
+
| `getAllPoolStatuses(poolUrls)` | Fetches `/pressure` from all pools in parallel |
|
|
57
|
+
| `getAggregatedPoolStatus(poolUrls)` | Combined view: `totalRunning`, `totalMaxConcurrent`, per-pool details |
|
|
58
|
+
| `waitForAnyPool(poolUrls)` | Blocks until at least one pool is reachable + available |
|
|
59
|
+
| `selectPool(poolUrls)` | Picks pool with lowest pressure ratio |
|
|
60
|
+
| `selectAndConnect(config)` | Convenience: selectPool + connectToPool in one call |
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Network Debugging Reference
|
|
2
|
+
|
|
3
|
+
## Network Error Handling
|
|
4
|
+
|
|
5
|
+
### `assert_no_network_errors` action
|
|
6
|
+
|
|
7
|
+
Checks accumulated `requestfailed` events during the test. If any network errors exist (e.g., `net::ERR_CONNECTION_REFUSED`), the test fails with details of each error URL. Place after critical page loads.
|
|
8
|
+
|
|
9
|
+
### `failOnNetworkError` config option
|
|
10
|
+
|
|
11
|
+
When `true`, automatically fails any test that has network errors after all actions complete. Default: `false` (opt-in).
|
|
12
|
+
|
|
13
|
+
Set via: config `failOnNetworkError: true` | CLI `--fail-on-network-error` | env `FAIL_ON_NETWORK_ERROR=true` | MCP `failOnNetworkError: true`
|
|
14
|
+
|
|
15
|
+
### `networkIgnoreDomains` config option
|
|
16
|
+
|
|
17
|
+
Array of domain substrings to filter from network error tracking. Errors from matching URLs are silently dropped by both `assert_no_network_errors` and `failOnNetworkError`.
|
|
18
|
+
|
|
19
|
+
Set via: config `networkIgnoreDomains: ['google-analytics.com', 'fonts.googleapis.com']` | CLI `--network-ignore-domains ga.com,fonts.com` | env `NETWORK_IGNORE_DOMAINS=ga.com,fonts.com` (comma-separated)
|
|
20
|
+
|
|
21
|
+
## Network Request/Response Logging
|
|
22
|
+
|
|
23
|
+
All XHR/fetch requests are captured with full detail regardless of status code:
|
|
24
|
+
|
|
25
|
+
- `url`, `method`, `status`, `statusText`, `duration`
|
|
26
|
+
- `requestHeaders` — all request headers as object
|
|
27
|
+
- `requestBody` — POST body (from `req.postData()`)
|
|
28
|
+
- `responseHeaders` — all response headers as object
|
|
29
|
+
- `responseBody` — full response text (truncated at 50KB)
|
|
30
|
+
|
|
31
|
+
Response bodies are read asynchronously and flushed via `Promise.allSettled` before the browser disconnects. Data is stored in the `network_logs` column in SQLite and displayed in the dashboard.
|
|
32
|
+
|
|
33
|
+
## MCP Response Optimization
|
|
34
|
+
|
|
35
|
+
The `e2e_run` MCP tool returns a compact `networkSummary` instead of full logs (~5KB vs ~400KB):
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"networkSummary": [{
|
|
40
|
+
"name": "test-name",
|
|
41
|
+
"totalRequests": 37,
|
|
42
|
+
"statusDistribution": { "2xx": 30, "3xx": 5, "4xx": 1, "5xx": 0, "other": 1 },
|
|
43
|
+
"avgDurationMs": 245,
|
|
44
|
+
"failedRequests": [{ "url": "/api/x", "method": "POST", "status": 500 }],
|
|
45
|
+
"slowestRequests": [{ "url": "/api/y", "method": "GET", "status": 200, "duration": 1200 }]
|
|
46
|
+
}]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Drill-Down Pattern
|
|
51
|
+
|
|
52
|
+
The response includes `runDbId` — the SQLite row ID. Use it with `e2e_network_logs` to drill down:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
1. e2e_run → compact summary + runDbId
|
|
56
|
+
2. e2e_network_logs(runDbId) → all requests (url, method, status, duration)
|
|
57
|
+
3. e2e_network_logs(runDbId, errorsOnly: true) → only failed requests
|
|
58
|
+
4. e2e_network_logs(runDbId, includeHeaders: true) → with headers
|
|
59
|
+
5. e2e_network_logs(runDbId, includeBodies: true) → full request/response bodies
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Dashboard REST equivalent: `GET /api/db/runs/:id/network-logs?testName=X&errorsOnly=true&includeHeaders=true`
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Test JSON Format Reference
|
|
2
|
+
|
|
3
|
+
## Basic Format (Array)
|
|
4
|
+
|
|
5
|
+
A test file is a JSON array of test objects:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
"name": "test-name",
|
|
11
|
+
"actions": [
|
|
12
|
+
{ "type": "goto", "value": "/page" },
|
|
13
|
+
{ "type": "assert_text", "text": "Expected content" }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Object Format (with Hooks)
|
|
20
|
+
|
|
21
|
+
When hooks are needed, use the object format:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"hooks": {
|
|
26
|
+
"beforeAll": [{ "type": "goto", "value": "/setup" }],
|
|
27
|
+
"beforeEach": [{ "type": "goto", "value": "/" }],
|
|
28
|
+
"afterEach": [],
|
|
29
|
+
"afterAll": []
|
|
30
|
+
},
|
|
31
|
+
"tests": [
|
|
32
|
+
{ "name": "test-1", "actions": [...] }
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Hook lifecycle:**
|
|
38
|
+
- `beforeAll` — runs once before all tests (on a separate browser page, state does NOT carry over)
|
|
39
|
+
- `beforeEach` — runs before each individual test (on the test's own page)
|
|
40
|
+
- `afterEach` — runs after each test
|
|
41
|
+
- `afterAll` — runs once after all tests
|
|
42
|
+
|
|
43
|
+
> **Warning**: `beforeAll` runs on a separate page that closes before tests start. Don't use it for browser state setup (cookies, localStorage). Use `beforeEach` instead.
|
|
44
|
+
|
|
45
|
+
## Test Options
|
|
46
|
+
|
|
47
|
+
| Field | Type | Description |
|
|
48
|
+
|-------|------|-------------|
|
|
49
|
+
| `name` | string | **Required.** Test identifier. |
|
|
50
|
+
| `actions` | array | **Required.** Sequential browser actions. |
|
|
51
|
+
| `expect` | string | Visual verification description. Triggers auto-screenshot + AI judgment. |
|
|
52
|
+
| `serial` | boolean | Run sequentially after all parallel tests (for shared state). |
|
|
53
|
+
| `retries` | number | Per-test retry count on failure. Overrides global config. |
|
|
54
|
+
| `timeout` | number | Per-test timeout in ms. Overrides global `testTimeout` (default 60000). |
|
|
55
|
+
|
|
56
|
+
## Serial Tests
|
|
57
|
+
|
|
58
|
+
Tests that share mutable state should be marked serial to prevent race conditions:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{ "name": "create-record", "serial": true, "actions": [...] },
|
|
62
|
+
{ "name": "verify-record", "serial": true, "actions": [...] }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Serial tests run one-at-a-time **after** all parallel tests finish.
|
|
66
|
+
|
|
67
|
+
## Retry Behavior
|
|
68
|
+
|
|
69
|
+
### Test-level retries
|
|
70
|
+
```json
|
|
71
|
+
{ "name": "flaky-test", "retries": 3, "actions": [...] }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or globally: `--retries 2` / `retries: 2` in config. Each retry gets its own timeout. Flaky tests (pass after retry) are logged as "flaky".
|
|
75
|
+
|
|
76
|
+
### Action-level retries
|
|
77
|
+
```json
|
|
78
|
+
{ "type": "click", "selector": "#dynamic-btn", "retries": 3 }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Or globally: `--action-retries 2`. Delay between action retries: `actionRetryDelay` (default 500ms).
|
|
82
|
+
|
|
83
|
+
## Reusable Modules
|
|
84
|
+
|
|
85
|
+
Create modules with `e2e_create_module`, reference them in tests:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"name": "login-test",
|
|
90
|
+
"actions": [
|
|
91
|
+
{ "$use": "auth-login", "params": { "email": "admin@test.com", "password": "secret" } },
|
|
92
|
+
{ "type": "assert_url", "value": "/dashboard" }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Module definition (in `e2e/modules/auth-login.json`):
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"$module": "auth-login",
|
|
101
|
+
"description": "Log in with email/password",
|
|
102
|
+
"params": {
|
|
103
|
+
"email": { "required": true, "description": "User email" },
|
|
104
|
+
"password": { "required": true, "description": "User password" }
|
|
105
|
+
},
|
|
106
|
+
"actions": [
|
|
107
|
+
{ "type": "goto", "value": "/login" },
|
|
108
|
+
{ "type": "type", "selector": "#email", "value": "{{email}}" },
|
|
109
|
+
{ "type": "type", "selector": "#password", "value": "{{password}}" },
|
|
110
|
+
{ "type": "click", "text": "Sign In" },
|
|
111
|
+
{ "type": "wait", "selector": ".dashboard" }
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Suite Naming & Ordering
|
|
117
|
+
|
|
118
|
+
Files can have numeric prefixes for execution order:
|
|
119
|
+
- `01-auth.json`, `02-dashboard.json`, `03-settings.json`
|
|
120
|
+
|
|
121
|
+
The `--suite` flag strips the prefix when matching: `--suite auth` finds `01-auth.json`.
|
|
122
|
+
|
|
123
|
+
## Excluding Tests
|
|
124
|
+
|
|
125
|
+
Use `exclude` in config to skip files when running `--all`:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
// e2e.config.js
|
|
129
|
+
export default {
|
|
130
|
+
exclude: ['explore-*', 'debug-*', 'draft-*']
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Individual `--suite` runs are not affected by exclude patterns.
|
|
135
|
+
|
|
136
|
+
## Environment Profiles
|
|
137
|
+
|
|
138
|
+
Define named profiles in config:
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
// e2e.config.js
|
|
142
|
+
export default {
|
|
143
|
+
baseUrl: 'http://host.docker.internal:3000',
|
|
144
|
+
environments: {
|
|
145
|
+
staging: { baseUrl: 'https://staging.example.com' },
|
|
146
|
+
production: { baseUrl: 'https://example.com', concurrency: 5 }
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Activate with `--env staging` or `E2E_ENV=staging`. Profile values override all other config.
|
|
152
|
+
|
|
153
|
+
## CI Output Formats
|
|
154
|
+
|
|
155
|
+
Use `--output <format>` to control report output: `json` (default), `junit` (JUnit XML), or `both`. JUnit XML is generated without external dependencies and saved to `{screenshotsDir}/junit.xml`. The `generateJUnitXML()` function is also exported from the programmatic API.
|
|
156
|
+
|
|
157
|
+
## Config Priority (ascending)
|
|
158
|
+
|
|
159
|
+
1. Hardcoded defaults
|
|
160
|
+
2. `e2e.config.js` or `e2e.config.json`
|
|
161
|
+
3. Environment variables (`BASE_URL`, `CONCURRENCY`, etc.)
|
|
162
|
+
4. CLI flags (`--base-url`, `--concurrency`, etc.)
|
|
163
|
+
5. Environment profile merge (via `--env`)
|