e2e 0.15.0 → 0.15.2

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.
Files changed (90) hide show
  1. package/README.md +70 -14
  2. package/dist/.build.json +1 -1
  3. package/dist/agent/act.js +3 -3
  4. package/dist/agent/act.js.map +1 -1
  5. package/dist/agent/error.d.ts +16 -3
  6. package/dist/agent/error.d.ts.map +1 -1
  7. package/dist/agent/error.js +25 -6
  8. package/dist/agent/error.js.map +1 -1
  9. package/dist/agent/model/tool-choice.d.ts +24 -1
  10. package/dist/agent/model/tool-choice.d.ts.map +1 -1
  11. package/dist/agent/model/tool-choice.js +27 -1
  12. package/dist/agent/model/tool-choice.js.map +1 -1
  13. package/dist/agent/step-cache.d.ts +14 -3
  14. package/dist/agent/step-cache.d.ts.map +1 -1
  15. package/dist/agent/step-cache.js +13 -3
  16. package/dist/agent/step-cache.js.map +1 -1
  17. package/dist/agent/tool-loop.d.ts.map +1 -1
  18. package/dist/agent/tool-loop.js +62 -9
  19. package/dist/agent/tool-loop.js.map +1 -1
  20. package/dist/cache/context.d.ts +19 -6
  21. package/dist/cache/context.d.ts.map +1 -1
  22. package/dist/cache/context.js +15 -21
  23. package/dist/cache/context.js.map +1 -1
  24. package/dist/cli/init/scaffold.d.ts +1 -0
  25. package/dist/cli/init/scaffold.d.ts.map +1 -1
  26. package/dist/cli/init/scaffold.js +2 -1
  27. package/dist/cli/init/scaffold.js.map +1 -1
  28. package/dist/cli/init/sibling-versions.json +1 -1
  29. package/dist/cli/signals.d.ts +2 -2
  30. package/dist/cli/signals.js +2 -2
  31. package/dist/expect/values.js +1 -1
  32. package/dist/expect/values.js.map +1 -1
  33. package/dist/run/execute.d.ts.map +1 -1
  34. package/dist/run/execute.js +21 -8
  35. package/dist/run/execute.js.map +1 -1
  36. package/dist/types.d.ts +1 -1
  37. package/dist/types.d.ts.map +1 -1
  38. package/docs/agent-steps.mdx +126 -0
  39. package/docs/agents.mdx +217 -0
  40. package/docs/api-testing.mdx +65 -0
  41. package/docs/authentication.mdx +345 -0
  42. package/docs/browser.mdx +440 -0
  43. package/docs/bug-bash.mdx +90 -0
  44. package/docs/cache.mdx +306 -0
  45. package/docs/ci.mdx +210 -0
  46. package/docs/coding-agents.mdx +183 -0
  47. package/docs/debugging.mdx +291 -0
  48. package/docs/executors.mdx +243 -0
  49. package/docs/explore.mdx +174 -0
  50. package/docs/github.mdx +184 -0
  51. package/docs/index.mdx +82 -0
  52. package/docs/integrations/eas.mdx +216 -0
  53. package/docs/integrations/index.mdx +24 -0
  54. package/docs/integrations/kernel.mdx +163 -0
  55. package/docs/migrate/cypress.mdx +124 -0
  56. package/docs/migrate/detox.mdx +140 -0
  57. package/docs/migrate/maestro.mdx +229 -0
  58. package/docs/migrate/playwright.mdx +427 -0
  59. package/docs/migrate/selenium.mdx +110 -0
  60. package/docs/mobile-ci.mdx +567 -0
  61. package/docs/mobile.mdx +555 -0
  62. package/docs/models.mdx +241 -0
  63. package/docs/quickstart.mdx +260 -0
  64. package/docs/reference/agent.mdx +524 -0
  65. package/docs/reference/app.mdx +72 -0
  66. package/docs/reference/cli.mdx +817 -0
  67. package/docs/reference/config.mdx +986 -0
  68. package/docs/reference/engine.mdx +1362 -0
  69. package/docs/reference/environment.mdx +113 -0
  70. package/docs/reference/errors.mdx +143 -0
  71. package/docs/reference/expect.mdx +513 -0
  72. package/docs/reference/mcp.mdx +202 -0
  73. package/docs/reference/mobile.mdx +522 -0
  74. package/docs/reference/reporters.mdx +216 -0
  75. package/docs/reference/screen.mdx +688 -0
  76. package/docs/reference/test.mdx +449 -0
  77. package/docs/reference/web.mdx +611 -0
  78. package/docs/security.mdx +292 -0
  79. package/docs/starting-your-app.mdx +231 -0
  80. package/docs/subscriptions.mdx +157 -0
  81. package/docs/telemetry.mdx +185 -0
  82. package/docs/tools.mdx +150 -0
  83. package/docs/viewports.mdx +146 -0
  84. package/docs/writing-an-engine.mdx +316 -0
  85. package/docs/writing-tests.mdx +256 -0
  86. package/package.json +15 -9
  87. package/skills/e2e/SKILL.md +7 -3
  88. package/skills/e2e/references/agent.md +3 -1
  89. package/skills/e2e/references/running.md +1 -1
  90. package/skills/e2e/references/setup.md +16 -6
@@ -0,0 +1,216 @@
1
+ ---
2
+ title: Reporters
3
+ description: Receive run events and publish results with a custom reporter.
4
+ ---
5
+
6
+ Add reporter objects to `reporters` in `e2e.config.ts`, alongside the
7
+ [built-in reporters](/reference/cli#output). Use `onEvent` for live progress
8
+ and `onRunFinished` to process the final report and artifacts.
9
+
10
+ ```ts
11
+ import type { E2EConfig, Reporter } from 'e2e';
12
+ import { web } from '@e2e-dev/web';
13
+
14
+ const upload: Reporter = {
15
+ name: 'upload',
16
+ async onRunFinished(run) {
17
+ const response = await fetch('https://example.test/runs', {
18
+ method: 'POST',
19
+ body: JSON.stringify(run.report),
20
+ });
21
+ const { url } = (await response.json()) as { url: string };
22
+ return [{ label: 'Results', text: url }];
23
+ },
24
+ };
25
+
26
+ export default {
27
+ targets: [{ engine: web(), app: { url: 'localhost:3000' } }],
28
+ reporters: ['list', upload],
29
+ } satisfies E2EConfig;
30
+ ```
31
+
32
+ ## The contract
33
+
34
+ ```ts
35
+ interface Reporter {
36
+ readonly name: string;
37
+ onEvent?(event: RunEvent): void;
38
+ onRunFinished?(run: FinishedRun, signal: AbortSignal): Promise<ReporterSummary | void>;
39
+ }
40
+
41
+ interface FinishedRun {
42
+ readonly report: Report; // the report-1 document, as written
43
+ readonly status: RunStatus; // report.run.status
44
+ readonly exitCode: RunExitCode;
45
+ readonly projectRoot: string; // what the terminal shows paths relative to
46
+ readonly reportPath: string | undefined; // absent when the write failed
47
+ readonly artifactsRoot: string; // what the report's artifact paths are relative to
48
+ readonly aiTracePath: string | undefined;
49
+ readonly lastRun?: Report; // with --last-failed, the report the rerun selected from
50
+ }
51
+
52
+ type ReporterSummary = readonly { label: string; text: string }[];
53
+ ```
54
+
55
+ `Reporter`, `FinishedRun`, `ReporterSummary`, `Report`, `RunEvent`, and
56
+ `RunEventOf` are exported from the main entrypoint.
57
+
58
+ The built-in `junit` reporter is the smallest complete example: it reads
59
+ `run.report`, writes `junit.xml` beside `run.reportPath`, and returns one row
60
+ naming the file. `markdown` does the same with `summary.md` through
61
+ `renderMarkdownReport(report, options)`, also exported, so your own reporter
62
+ can post the same page elsewhere; `failurePages` links each block to a page
63
+ by result id. The built-in reporter also writes one page per failed or flaky
64
+ test under `failures/`, with the screen at failure inline. [`@e2e-dev/github`](/github) is that
65
+ reporter for GitHub Actions.
66
+
67
+ A name and at least one handler are required; anything else is
68
+ `INVALID_CONFIG`.
69
+
70
+ ## The event stream
71
+
72
+ `onEvent` receives run progress as plain JSON. The `list` reporter uses the
73
+ same events. Each event has a sequence number, `seq`, and an ISO timestamp,
74
+ `at`.
75
+
76
+ ```ts
77
+ type RunEventFact =
78
+ | { type: 'run-started'; runId; projectId; projectRoot; artifactsRoot; ci; targets; agents?; model?; judge? }
79
+ | { type: 'plan'; total; files: { file; target; tests }[] }
80
+ | { type: 'notice'; target; message }
81
+ | { type: 'output'; target; pair; stream: 'stdout' | 'stderr'; text }
82
+ | { type: 'setup'; step: SetupStep; state: 'started' }
83
+ | { type: 'setup'; step: SetupStep; state: 'finished'; durationMs; outcome?: 'reused' }
84
+ | { type: 'test-started'; testId; agent; repeat; title; file; serialId; target }
85
+ | { type: 'step'; testId; agent; repeat; target; progress: StepProgress }
86
+ | { type: 'test-finished'; result: RunEventResult }
87
+ | { type: 'serial-group'; group: SerialGroupRecord }
88
+ | { type: 'explore'; progress: ExploreProgress }
89
+ | { type: 'run-error'; error: SerializedError }
90
+ | { type: 'run-interrupted'; mode: 'graceful' | 'forced' }
91
+ | { type: 'run-stopped'; failures; limit }
92
+ | { type: 'run-finished'; status; exitCode; reportPath?; aiTracePath? };
93
+ ```
94
+
95
+ `output` is one write a test made to stdout or stderr; `pair` names the test
96
+ running at the time and is undefined between tests. `judge` on `run-started`
97
+ is the run agent's judge model, present only when judgments use a model other
98
+ than `model`.
99
+
100
+ The `phase` field describes step progress:
101
+
102
+ - `start` and `end` mark the step's boundaries.
103
+ - `event` reports a completed model turn, tool call, or observation.
104
+ - `activity` reports work starting: `observe`, `action`, or `model`.
105
+ - `replay` reports when replay from the cache starts or returns control to the agent.
106
+
107
+ ```ts
108
+ type StepProgress = (
109
+ | { phase: 'start'; kind: StepKind; api: string; label: string }
110
+ | {
111
+ phase: 'end';
112
+ kind: StepKind;
113
+ api: string;
114
+ label: string;
115
+ status: 'passed' | 'failed' | 'blocked' | 'timed-out' | 'cancelled';
116
+ durationMs: number;
117
+ modelCalls: number;
118
+ error?: SerializedError;
119
+ explanation?: string;
120
+ }
121
+ | { phase: 'event'; api: string; event: StepEvent }
122
+ | { phase: 'activity'; api: string; activity: 'observe' | 'model' | 'action' }
123
+ | { phase: 'replay'; api: string; active: boolean }
124
+ ) & { identity?: StepProgressIdentity };
125
+ ```
126
+
127
+ Every step phase emitted by the runner includes `progress.identity`:
128
+
129
+ ```ts
130
+ { attemptId: string; attemptIndex: number; stepId: string; stepIndex: number }
131
+ ```
132
+
133
+ The IDs match the final report. Both indexes start at zero. A retry has a
134
+ new attempt ID and a higher attempt index; its step indexes start again at
135
+ zero. Serial-group members share the group's attempt ID and index, while
136
+ each member's step IDs remain distinct. Use `stepId` to match start, activity,
137
+ event, replay, and end phases, including nested steps. `identity` is optional
138
+ in the type so a reporter can also accept older streams.
139
+
140
+ An `end` phase also includes the step's redacted `error` and `explanation`
141
+ when present. Preserve its `status`, including `blocked` and `cancelled`,
142
+ instead of treating every non-passed step as a product failure.
143
+
144
+ `explore` appears only in an `e2e explore` run: `started`, `planning`,
145
+ `step-started`, `step-finished`, `finding`, and `finished`. The record of all
146
+ of it is `run.explore` in the report.
147
+
148
+ New event types are added over time. Handle the types you know and ignore
149
+ the rest; leave the `default` branch of a `switch` empty.
150
+
151
+ `run-started` comes first and `run-finished` last. `test-finished` carries the
152
+ full result record, including every attempt's artifacts. A test pinned to
153
+ several agents starts and finishes once per agent, so key running state by
154
+ test id, target, and agent together. Ordinary tests emit `test-started` once
155
+ for that combination. Serial members emit it on each group attempt they
156
+ execute. Use step progress identity to distinguish retries. An attempt
157
+ that fails before any step emits no step progress and appears in the final
158
+ result. Secrets are redacted before events are
159
+ built. Error messages are only stripped of control characters; treat them as
160
+ untrusted.
161
+
162
+ `onEvent` must not block and must not throw. A throw quarantines the reporter
163
+ for the rest of the run and prints one line on stderr naming the reporter, the
164
+ event type, and the error; the run's outcome is unchanged. Slow work belongs
165
+ in `onRunFinished`.
166
+
167
+ ## The finished run
168
+
169
+ `onRunFinished` runs after the report is written and the terminal summary
170
+ prints. All reporters run concurrently, each with a one-minute deadline.
171
+ A timeout, exception, or invalid return value is reported on stderr without
172
+ changing the run's status, exit code, or report.
173
+
174
+ One Ctrl-C still lets reporters finish. A second Ctrl-C stops waiting for them.
175
+
176
+ The second argument is an `AbortSignal` that aborts when the budget runs out
177
+ or the run is forced to stop. Hand it to every request and timer, or an
178
+ abandoned reporter keeps the CLI alive after the run has ended.
179
+
180
+ With `--last-failed`, `lastRun` is the report the rerun selected from. The
181
+ rerun's own report lists the tests it left out as unselected, so a reporter
182
+ that keeps one place current, the way `@e2e-dev/github` keeps a pull request
183
+ comment, folds the rerun into `lastRun` to show both runs as one.
184
+
185
+ The rows a reporter resolves with print under the `list` summary in the same
186
+ layout as `Report`; the `json` reporter does not carry them:
187
+
188
+ ```
189
+ Test Files 2 passed (2)
190
+ Tests 6 passed (6)
191
+ Start at 14:02:11
192
+ Duration 8.41s
193
+ Report .e2e/report.json
194
+
195
+ JUnit .e2e/junit.xml
196
+ Results https://example.test/runs/0192c…
197
+ ```
198
+
199
+ Artifact paths in the report are POSIX paths relative to `artifactsRoot`.
200
+ `path`, `size`, and `sha256` are optional: an artifact whose file never
201
+ appeared, or that a redaction withheld, is recorded without them. Check for
202
+ `path` before reading. A video a hosted service keeps has an `http(s)` `url`
203
+ in place of `path`.
204
+
205
+ ## What `--reporter` does to reporter objects
206
+
207
+ `--reporter` replaces only the built-in reporters; configured reporter
208
+ objects still run. A config with only reporter objects has no built-in
209
+ terminal output.
210
+
211
+ ## Where a reporter runs
212
+
213
+ Handlers run in the runner process. Workers also load the config, so reporter
214
+ construction must have no side effects. Read tokens and start requests inside
215
+ handlers. Adding a reporter leaves [cached traces](/cache#what-must-match)
216
+ valid.