@e2edev/e2e 0.4.0 → 0.5.1

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 (256) hide show
  1. package/README.md +41 -15
  2. package/dist/agent/act.d.ts +1 -1
  3. package/dist/agent/act.js +12 -36
  4. package/dist/agent/act.js.map +1 -1
  5. package/dist/agent/actions.d.ts +2 -2
  6. package/dist/agent/actions.d.ts.map +1 -1
  7. package/dist/agent/actions.js +1 -1
  8. package/dist/agent/default-agent.d.ts +3 -29
  9. package/dist/agent/default-agent.d.ts.map +1 -1
  10. package/dist/agent/default-agent.js +4 -11
  11. package/dist/agent/default-agent.js.map +1 -1
  12. package/dist/agent/error.d.ts +0 -2
  13. package/dist/agent/error.d.ts.map +1 -1
  14. package/dist/agent/error.js +1 -3
  15. package/dist/agent/error.js.map +1 -1
  16. package/dist/agent/executor.d.ts +15 -49
  17. package/dist/agent/executor.d.ts.map +1 -1
  18. package/dist/agent/executor.js +0 -1
  19. package/dist/agent/executor.js.map +1 -1
  20. package/dist/agent/index.js +2 -2
  21. package/dist/agent/invocation.d.ts +6 -4
  22. package/dist/agent/invocation.d.ts.map +1 -1
  23. package/dist/agent/invocation.js +2 -2
  24. package/dist/agent/invocation.js.map +1 -1
  25. package/dist/agent/ledger.d.ts +16 -11
  26. package/dist/agent/ledger.d.ts.map +1 -1
  27. package/dist/agent/ledger.js +5 -8
  28. package/dist/agent/ledger.js.map +1 -1
  29. package/dist/agent/observation.d.ts +6 -6
  30. package/dist/agent/observation.d.ts.map +1 -1
  31. package/dist/agent/observation.js +5 -5
  32. package/dist/agent/observation.js.map +1 -1
  33. package/dist/agent/phases.d.ts +3 -3
  34. package/dist/agent/phases.d.ts.map +1 -1
  35. package/dist/agent/phases.js +4 -4
  36. package/dist/agent/phases.js.map +1 -1
  37. package/dist/agent/primitives.d.ts +4 -25
  38. package/dist/agent/primitives.d.ts.map +1 -1
  39. package/dist/agent/primitives.js +3 -36
  40. package/dist/agent/primitives.js.map +1 -1
  41. package/dist/agent/protocol.d.ts +1 -1
  42. package/dist/agent/protocol.js +1 -1
  43. package/dist/agent/public.d.ts +7 -9
  44. package/dist/agent/public.d.ts.map +1 -1
  45. package/dist/agent/public.js +6 -7
  46. package/dist/agent/public.js.map +1 -1
  47. package/dist/agent/replay.d.ts +1 -1
  48. package/dist/agent/replay.d.ts.map +1 -1
  49. package/dist/agent/secrets.d.ts +2 -2
  50. package/dist/agent/secrets.d.ts.map +1 -1
  51. package/dist/agent/secrets.js +3 -3
  52. package/dist/agent/secrets.js.map +1 -1
  53. package/dist/agent/tool-loop.d.ts +2 -30
  54. package/dist/agent/tool-loop.d.ts.map +1 -1
  55. package/dist/agent/tool-loop.js +9 -33
  56. package/dist/agent/tool-loop.js.map +1 -1
  57. package/dist/agent/tool.d.ts +4 -5
  58. package/dist/agent/tool.d.ts.map +1 -1
  59. package/dist/agent/tool.js +2 -7
  60. package/dist/agent/tool.js.map +1 -1
  61. package/dist/cache/anchors.d.ts +1 -1
  62. package/dist/cache/anchors.d.ts.map +1 -1
  63. package/dist/cache/identity.d.ts +8 -8
  64. package/dist/cache/identity.d.ts.map +1 -1
  65. package/dist/cache/identity.js +5 -5
  66. package/dist/cache/identity.js.map +1 -1
  67. package/dist/cache/relocate.d.ts +1 -1
  68. package/dist/cache/relocate.d.ts.map +1 -1
  69. package/dist/cli/index.js +3 -3
  70. package/dist/cli/index.js.map +1 -1
  71. package/dist/cli/init/{backends.d.ts → engines.d.ts} +12 -13
  72. package/dist/cli/init/engines.d.ts.map +1 -0
  73. package/dist/cli/init/{backends.js → engines.js} +13 -14
  74. package/dist/cli/init/engines.js.map +1 -0
  75. package/dist/cli/init/scaffold.d.ts +3 -3
  76. package/dist/cli/init/scaffold.d.ts.map +1 -1
  77. package/dist/cli/init/scaffold.js +9 -9
  78. package/dist/cli/init/scaffold.js.map +1 -1
  79. package/dist/cli/init.d.ts.map +1 -1
  80. package/dist/cli/init.js +11 -10
  81. package/dist/cli/init.js.map +1 -1
  82. package/dist/cli/signals.d.ts +1 -1
  83. package/dist/cli/signals.d.ts.map +1 -1
  84. package/dist/cli/signals.js +1 -1
  85. package/dist/cli/signals.js.map +1 -1
  86. package/dist/collect/collect.d.ts +32 -3
  87. package/dist/collect/collect.d.ts.map +1 -1
  88. package/dist/collect/collect.js +95 -17
  89. package/dist/collect/collect.js.map +1 -1
  90. package/dist/collect/registry.js +1 -1
  91. package/dist/collect/registry.js.map +1 -1
  92. package/dist/collect/select.d.ts.map +1 -1
  93. package/dist/collect/select.js +9 -5
  94. package/dist/collect/select.js.map +1 -1
  95. package/dist/config/app.d.ts +76 -19
  96. package/dist/config/app.d.ts.map +1 -1
  97. package/dist/config/app.js +157 -102
  98. package/dist/config/app.js.map +1 -1
  99. package/dist/config/resolve.d.ts +6 -5
  100. package/dist/config/resolve.d.ts.map +1 -1
  101. package/dist/config/resolve.js +35 -32
  102. package/dist/config/resolve.js.map +1 -1
  103. package/dist/{backend → engine}/contract.d.ts +26 -18
  104. package/dist/engine/contract.d.ts.map +1 -0
  105. package/dist/{backend → engine}/contract.js +18 -18
  106. package/dist/engine/contract.js.map +1 -0
  107. package/dist/{backend → engine}/index.d.ts +141 -79
  108. package/dist/engine/index.d.ts.map +1 -0
  109. package/dist/{backend → engine}/index.js +60 -35
  110. package/dist/engine/index.js.map +1 -0
  111. package/dist/engine/session.d.ts +23 -0
  112. package/dist/engine/session.d.ts.map +1 -0
  113. package/dist/{backend → engine}/session.js +55 -51
  114. package/dist/engine/session.js.map +1 -0
  115. package/dist/{backend → engine}/surface.d.ts +11 -11
  116. package/dist/engine/surface.d.ts.map +1 -0
  117. package/dist/{backend → engine}/surface.js +2 -2
  118. package/dist/engine/surface.js.map +1 -0
  119. package/dist/engine/timing.d.ts.map +1 -0
  120. package/dist/engine/timing.js +8 -0
  121. package/dist/engine/timing.js.map +1 -0
  122. package/dist/expect/index.js +1 -1
  123. package/dist/index.d.ts +3 -2
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +1 -1
  126. package/dist/index.js.map +1 -1
  127. package/dist/internal/brands.d.ts +1 -1
  128. package/dist/internal/brands.d.ts.map +1 -1
  129. package/dist/internal/brands.js +1 -1
  130. package/dist/internal/brands.js.map +1 -1
  131. package/dist/internal/errors.d.ts +16 -16
  132. package/dist/internal/errors.d.ts.map +1 -1
  133. package/dist/internal/errors.js +39 -39
  134. package/dist/internal/errors.js.map +1 -1
  135. package/dist/internal/objects.d.ts +21 -0
  136. package/dist/internal/objects.d.ts.map +1 -0
  137. package/dist/internal/objects.js +14 -0
  138. package/dist/internal/objects.js.map +1 -0
  139. package/dist/internal/urls.d.ts +1 -1
  140. package/dist/internal/urls.d.ts.map +1 -1
  141. package/dist/internal/urls.js +6 -1
  142. package/dist/internal/urls.js.map +1 -1
  143. package/dist/locator/engine.d.ts +6 -6
  144. package/dist/locator/engine.d.ts.map +1 -1
  145. package/dist/locator/engine.js +13 -13
  146. package/dist/locator/engine.js.map +1 -1
  147. package/dist/locator/expression.d.ts +4 -2
  148. package/dist/locator/expression.d.ts.map +1 -1
  149. package/dist/locator/expression.js +24 -4
  150. package/dist/locator/expression.js.map +1 -1
  151. package/dist/locator/screen.d.ts +1 -1
  152. package/dist/locator/screen.d.ts.map +1 -1
  153. package/dist/locator/screen.js +2 -2
  154. package/dist/locator/screen.js.map +1 -1
  155. package/dist/report/build.d.ts +9 -8
  156. package/dist/report/build.d.ts.map +1 -1
  157. package/dist/report/build.js +21 -18
  158. package/dist/report/build.js.map +1 -1
  159. package/dist/report/code-frame.d.ts +8 -4
  160. package/dist/report/code-frame.d.ts.map +1 -1
  161. package/dist/report/code-frame.js +23 -18
  162. package/dist/report/code-frame.js.map +1 -1
  163. package/dist/report/debug-steps.js +1 -1
  164. package/dist/report/debug-steps.js.map +1 -1
  165. package/dist/report/format.d.ts +73 -0
  166. package/dist/report/format.d.ts.map +1 -0
  167. package/dist/report/format.js +147 -0
  168. package/dist/report/format.js.map +1 -0
  169. package/dist/report/list.d.ts +96 -47
  170. package/dist/report/list.d.ts.map +1 -1
  171. package/dist/report/list.js +485 -244
  172. package/dist/report/list.js.map +1 -1
  173. package/dist/report/live-window.d.ts +28 -0
  174. package/dist/report/live-window.d.ts.map +1 -0
  175. package/dist/report/live-window.js +102 -0
  176. package/dist/report/live-window.js.map +1 -0
  177. package/dist/run/declared-processes.d.ts +30 -0
  178. package/dist/run/declared-processes.d.ts.map +1 -0
  179. package/dist/run/declared-processes.js +61 -0
  180. package/dist/run/declared-processes.js.map +1 -0
  181. package/dist/run/events.d.ts +30 -2
  182. package/dist/run/events.d.ts.map +1 -1
  183. package/dist/run/events.js.map +1 -1
  184. package/dist/run/execute.d.ts +17 -13
  185. package/dist/run/execute.d.ts.map +1 -1
  186. package/dist/run/execute.js +61 -62
  187. package/dist/run/execute.js.map +1 -1
  188. package/dist/run/fixture-recording.d.ts +10 -4
  189. package/dist/run/fixture-recording.d.ts.map +1 -1
  190. package/dist/run/fixture-recording.js +19 -6
  191. package/dist/run/fixture-recording.js.map +1 -1
  192. package/dist/run/fixtures.d.ts +1 -1
  193. package/dist/run/fixtures.d.ts.map +1 -1
  194. package/dist/run/fixtures.js +33 -41
  195. package/dist/run/fixtures.js.map +1 -1
  196. package/dist/run/in-process.d.ts +1 -1
  197. package/dist/run/in-process.js +1 -1
  198. package/dist/run/managed-process.d.ts +39 -9
  199. package/dist/run/managed-process.d.ts.map +1 -1
  200. package/dist/run/managed-process.js +102 -34
  201. package/dist/run/managed-process.js.map +1 -1
  202. package/dist/run/runner.d.ts +1 -1
  203. package/dist/run/runner.d.ts.map +1 -1
  204. package/dist/run/runner.js +67 -31
  205. package/dist/run/runner.js.map +1 -1
  206. package/dist/run/scheduler.d.ts +4 -3
  207. package/dist/run/scheduler.d.ts.map +1 -1
  208. package/dist/run/scheduler.js +5 -4
  209. package/dist/run/scheduler.js.map +1 -1
  210. package/dist/run/serial.d.ts +9 -1
  211. package/dist/run/serial.d.ts.map +1 -1
  212. package/dist/run/serial.js +2 -0
  213. package/dist/run/serial.js.map +1 -1
  214. package/dist/run/sessions.d.ts +9 -9
  215. package/dist/run/sessions.d.ts.map +1 -1
  216. package/dist/run/sessions.js +10 -10
  217. package/dist/run/sessions.js.map +1 -1
  218. package/dist/run/steps.d.ts +1 -1
  219. package/dist/run/steps.d.ts.map +1 -1
  220. package/dist/run/worker/entry.d.ts +1 -1
  221. package/dist/run/worker/entry.js +2 -2
  222. package/dist/run/worker/entry.js.map +1 -1
  223. package/dist/run/worker/protocol.d.ts +18 -6
  224. package/dist/run/worker/protocol.d.ts.map +1 -1
  225. package/dist/run/worker/protocol.js +1 -1
  226. package/dist/run/worker/protocol.js.map +1 -1
  227. package/dist/run/worker/session.d.ts +2 -2
  228. package/dist/run/worker/session.d.ts.map +1 -1
  229. package/dist/run/worker/session.js +5 -3
  230. package/dist/run/worker/session.js.map +1 -1
  231. package/dist/types.d.ts +36 -37
  232. package/dist/types.d.ts.map +1 -1
  233. package/package.json +5 -5
  234. package/dist/backend/contract.d.ts.map +0 -1
  235. package/dist/backend/contract.js.map +0 -1
  236. package/dist/backend/index.d.ts.map +0 -1
  237. package/dist/backend/index.js.map +0 -1
  238. package/dist/backend/session.d.ts +0 -23
  239. package/dist/backend/session.d.ts.map +0 -1
  240. package/dist/backend/session.js.map +0 -1
  241. package/dist/backend/surface.d.ts.map +0 -1
  242. package/dist/backend/surface.js.map +0 -1
  243. package/dist/backend/timing.d.ts.map +0 -1
  244. package/dist/backend/timing.js +0 -8
  245. package/dist/backend/timing.js.map +0 -1
  246. package/dist/cli/init/backends.d.ts.map +0 -1
  247. package/dist/cli/init/backends.js.map +0 -1
  248. package/dist/report/live-status.d.ts +0 -51
  249. package/dist/report/live-status.d.ts.map +0 -1
  250. package/dist/report/live-status.js +0 -163
  251. package/dist/report/live-status.js.map +0 -1
  252. package/dist/run/fixture-legacy.d.ts +0 -36
  253. package/dist/run/fixture-legacy.d.ts.map +0 -1
  254. package/dist/run/fixture-legacy.js +0 -143
  255. package/dist/run/fixture-legacy.js.map +0 -1
  256. /package/dist/{backend → engine}/timing.d.ts +0 -0
@@ -1,85 +1,96 @@
1
- /** Human-readable list reporter (spec 06-cli.md). */
1
+ /**
2
+ * Human-readable list reporter (spec 06-cli.md), styled after vitest's
3
+ * default reporter: one block per test file and target, a `Failed Tests`
4
+ * section with code frames, and a padded summary. On a TTY a live window
5
+ * below the log shows the running files, their tests, and the counters.
6
+ */
2
7
  import path from 'node:path';
3
8
  import picocolors from 'picocolors';
4
9
  import { sanitizeText, truncateUtf8 } from '../internal/errors.js';
10
+ import { packageVersion } from '../internal/package-version.js';
5
11
  import { collapseText } from '../internal/text.js';
6
12
  import { codeFrame, userFrame } from './code-frame.js';
7
- import { LiveStatus } from './live-status.js';
8
- const MAX_FIELD_BYTES = 8192;
13
+ import { addUsage, aiSegment, bounded, ellipsize, emptyCounters, emptyUsage, fileOutcome, formatClock, formatTime, formatTokens, padTitle, rule, stateString, statusBucket, stepsUsage, sumUsage, tally, terminalColumns, terminalRows, } from './format.js';
14
+ import { LiveWindow } from './live-window.js';
9
15
  /** Step labels stay one glanceable line; the report holds the full text. */
10
16
  const MAX_STEP_LABEL_BYTES = 72;
11
- function bounded(text) {
12
- return truncateUtf8(sanitizeText(text), MAX_FIELD_BYTES);
13
- }
17
+ const F_POINTER = '❯';
18
+ const F_CHECK = '✓';
19
+ const F_CROSS = '×';
20
+ const F_DOWN = '↓';
21
+ const F_RIGHT = '→';
22
+ const F_DOWN_RIGHT = '↳';
23
+ const F_TREE_MIDDLE = '├──';
24
+ const F_TREE_END = '└──';
25
+ /** Indentation under a badge line, matching vitest's banner padding. */
26
+ const BADGE_PADDING = ' ';
27
+ /** Badge backgrounds, assigned to targets in declaration order. */
28
+ const BADGE_COLORS = ['bgYellow', 'bgCyan', 'bgGreen', 'bgMagenta'];
29
+ /**
30
+ * Rows the live window spends outside the running tests and the summary: its
31
+ * blank lines, the `… more running` marker, and a margin above the prompt.
32
+ */
33
+ const WINDOW_CHROME_ROWS = 6;
34
+ /** Rows one running test takes before its calls: the test line and its current step. */
35
+ const WINDOW_ROWS_PER_TEST = 2;
36
+ /** Indentation of the `→ first error line` under a failed test in a file block. */
37
+ const ERROR_GLANCE_INDENT = 7;
14
38
  /** One-line, quoted step label bounded for the live view. */
15
39
  function stepLabel(label) {
16
40
  const flat = collapseText(label);
17
41
  const shown = truncateUtf8(flat, MAX_STEP_LABEL_BYTES);
18
42
  return `"${shown}${shown === flat ? '' : '…'}"`;
19
43
  }
20
- /** Human duration: milliseconds under a second, one decimal above. */
21
- function formatDuration(ms) {
22
- return ms < 1_000 ? `${ms}ms` : `${(ms / 1_000).toFixed(1)}s`;
23
- }
24
- /** Compact token count: plain under a thousand, `12.4k`, then `4.2M`. */
25
- function formatTokens(count) {
26
- if (count < 1_000)
27
- return `${count}`;
28
- if (count < 1_000_000)
29
- return `${(count / 1_000).toFixed(1)}k`;
30
- return `${(count / 1_000_000).toFixed(1)}M`;
31
- }
32
- /** USD with enough precision for sub-cent model calls. */
33
- function formatCost(costUsd) {
34
- return `$${costUsd.toFixed(costUsd < 0.1 ? 4 : 2)}`;
35
- }
36
- /** Accumulates the model usage of one step list into a running total. */
37
- function addStepsUsage(usage, steps) {
38
- for (const step of steps) {
39
- if (step.model === undefined)
40
- continue;
41
- usage.calls += step.model.calls;
42
- usage.tokens += step.model.inputTokens + step.model.outputTokens;
43
- if (step.model.estimatedCostUsd !== undefined) {
44
- usage.costUsd = (usage.costUsd ?? 0) + step.model.estimatedCostUsd;
45
- }
46
- }
47
- }
48
44
  /**
49
- * Sums model usage across every step of every attempt of one result. Serial
50
- * members carry no attempts of their own; their usage arrives once per group
51
- * through the `serial-group` event.
52
- */
53
- function aiUsage(result) {
54
- const usage = { calls: 0, tokens: 0, costUsd: undefined };
55
- for (const attempt of result.attempts)
56
- addStepsUsage(usage, attempt.steps);
57
- return usage;
58
- }
59
- /** One dim `ai …` segment, or undefined when the test used no model. */
60
- function aiSegment(usage) {
61
- if (usage.calls === 0)
62
- return undefined;
63
- const cost = usage.costUsd === undefined ? '' : ` · ${formatCost(usage.costUsd)}`;
64
- return `ai ${formatTokens(usage.tokens)} tokens${cost}`;
65
- }
66
- /**
67
- * Live tail for one step event. Model and backend calls are the ones worth a
45
+ * Live tail for one step event. Model and engine calls are the ones worth a
68
46
  * glance (`tool:` prefixes come from executor tool accounting); polls and
69
47
  * policy decisions stay quiet.
70
48
  */
71
49
  function eventTail(event) {
72
50
  if (event.kind === 'model') {
73
51
  const tokens = event.count !== undefined && event.count > 0 ? ` · ${formatTokens(event.count)} tokens` : '';
74
- return `model turn ${formatDuration(event.durationMs)}${tokens}`;
52
+ return `model turn ${formatTime(event.durationMs)}${tokens}`;
75
53
  }
76
- if (event.kind === 'backend') {
77
- const name = sanitizeText(event.name ?? 'backend').replace(/^tool:/, '');
78
- const failed = event.status === 'passed' ? '' : ' ✗';
79
- return `${truncateUtf8(name, 40)} ${formatDuration(event.durationMs)}${failed}`;
54
+ if (event.kind === 'engine') {
55
+ const name = sanitizeText(event.name ?? 'engine').replace(/^tool:/, '');
56
+ const failed = event.status === 'passed' ? '' : ` ${F_CROSS}`;
57
+ return `${truncateUtf8(name, 40)} ${formatTime(event.durationMs)}${failed}`;
80
58
  }
81
59
  return undefined;
82
60
  }
61
+ /** The identity of one test-target pair across `test-started`, `step`, and `test-finished`. */
62
+ function pairKey(testId, target) {
63
+ return `${testId}@${target}`;
64
+ }
65
+ /** Details of an ordinary result: summed over its attempts, the error from the last. */
66
+ function attemptDetails(attempts) {
67
+ return {
68
+ durationMs: attempts.reduce((total, attempt) => total + attempt.durationMs, 0),
69
+ usage: stepsUsage(attempts.map((attempt) => attempt.steps)),
70
+ error: attempts[attempts.length - 1]?.error,
71
+ };
72
+ }
73
+ /**
74
+ * Details of one serial member, read from its group: member results carry no
75
+ * attempts of their own. Duration and usage sum over every group attempt the
76
+ * member ran in. The error is the member's own from the last attempt; a member
77
+ * that attempt never ran (skipped, or absent after a launch failure) inherits
78
+ * the attempt's error, since that is what stopped it.
79
+ */
80
+ function serialMemberDetails(group, testId) {
81
+ const runs = group.attempts.map((attempt) => ({
82
+ attempt,
83
+ member: attempt.members.find((member) => member.testId === testId),
84
+ }));
85
+ const last = runs[runs.length - 1];
86
+ const own = last?.member;
87
+ const neverRan = own === undefined || own.status === 'skipped';
88
+ return {
89
+ durationMs: runs.reduce((total, run) => total + (run.member?.durationMs ?? 0), 0),
90
+ usage: stepsUsage(runs.map((run) => run.member?.steps ?? [])),
91
+ error: own?.error ?? (neverRan ? last?.attempt.error : undefined),
92
+ };
93
+ }
83
94
  const DEFAULT_OUTPUT = {
84
95
  write: (line) => process.stdout.write(`${line}\n`),
85
96
  raw: (text) => process.stdout.write(text),
@@ -91,31 +102,35 @@ const DEFAULT_OUTPUT = {
91
102
  */
92
103
  export class ListReporter {
93
104
  output;
94
- passed = 0;
95
- failed = 0;
96
- flaky = 0;
97
- skipped = 0;
98
- projectRoot;
99
- status;
100
- /** Base live-status text of each running pair, keyed `${testId}@${target}`. */
101
- liveBase = new Map();
102
- /** Current step line of each running pair, rendered under its header. */
103
- liveStep = new Map();
104
- /** Rolling window of the running step's latest model and backend calls. */
105
- liveEvents = new Map();
106
- /** Pairs whose permanent header line has been written. */
107
- headerPrinted = new Set();
108
- /** Run-wide model usage, summed from every reported result. */
109
- runAi = { calls: 0, tokens: 0, costUsd: undefined };
110
- /** Colors follow live rendering: non-interactive sinks get plain text. */
111
105
  pc;
106
+ window;
107
+ separator;
108
+ projectRoot;
109
+ /** Selected targets in declaration order; decides each badge's color. */
110
+ targets = [];
111
+ /** When the run began: the summary's `Start at` and the origin of `Duration`. */
112
+ startedAt = new Date();
113
+ /** File groups keyed `${target}\u0000${file}`, in first-seen order. */
114
+ groups = new Map();
115
+ /** Pairs executing right now, keyed by `pairKey`, in start order. */
116
+ running = new Map();
117
+ failures = [];
118
+ /**
119
+ * Serial groups whose members' results are still to come, by group id. The
120
+ * runner emits a group before its member results, and a member's details
121
+ * live only in the group.
122
+ */
123
+ pendingSerial = new Map();
112
124
  /** Run-level errors, printed once at the end; the stream carries them as they happen. */
113
125
  errors = [];
126
+ /** Run-wide model usage, summed from every reported result and serial group. */
127
+ runUsage = emptyUsage();
114
128
  constructor(output = DEFAULT_OUTPUT, options = {}) {
115
129
  this.output = output;
116
130
  const live = (options.live ?? process.stdout.isTTY === true) && output.raw !== undefined;
117
- this.status = new LiveStatus(live ? output.raw?.bind(output) : undefined);
118
- this.pc = picocolors.createColors(live);
131
+ this.pc = picocolors.createColors(options.colors ?? (live || picocolors.isColorSupported));
132
+ this.separator = this.pc.dim(' > ');
133
+ this.window = new LiveWindow(live ? output.raw?.bind(output) : undefined, () => this.renderWindow());
119
134
  }
120
135
  /**
121
136
  * The reporter as an event sink: one dispatch per fact. Bound, so it can be
@@ -127,10 +142,10 @@ export class ListReporter {
127
142
  this.runStarted(event);
128
143
  break;
129
144
  case 'plan':
130
- this.status.plan(event.total);
145
+ this.plan(event);
131
146
  break;
132
147
  case 'notice':
133
- this.writeAboveStatus(`${this.pc.dim('ℹ')} ${event.message}`);
148
+ this.print(`${this.pc.dim('ℹ')} ${bounded(event.message)}`);
134
149
  break;
135
150
  case 'test-started':
136
151
  this.testStarted(event);
@@ -155,233 +170,459 @@ export class ListReporter {
155
170
  break;
156
171
  }
157
172
  };
173
+ /** Writes one permanent line without disturbing the live window. */
174
+ print(line) {
175
+ this.window.erase();
176
+ this.output.write(line);
177
+ this.window.redraw();
178
+ }
179
+ /** A target's colored badge, `|web|` when colors are off (vitest's convention). */
180
+ badge(target) {
181
+ const name = bounded(target);
182
+ if (!this.pc.isColorSupported)
183
+ return `|${name}|`;
184
+ const index = Math.max(0, this.targets.indexOf(target));
185
+ const color = BADGE_COLORS[index % BADGE_COLORS.length];
186
+ return this.pc.black(this.pc[color](` ${name} `));
187
+ }
188
+ /** A path relative to the project root when inside it, else as given. */
189
+ displayPath(target) {
190
+ const inside = this.projectRoot !== undefined && target.startsWith(`${this.projectRoot}${path.sep}`);
191
+ return bounded(inside ? path.relative(this.projectRoot, target) : target);
192
+ }
193
+ group(file, target) {
194
+ const key = `${target}\u0000${file}`;
195
+ let group = this.groups.get(key);
196
+ if (group === undefined) {
197
+ group = { file, target, planned: undefined, lines: [], streamed: false, printed: false };
198
+ this.groups.set(key, group);
199
+ }
200
+ return group;
201
+ }
202
+ runStarted(event) {
203
+ const { pc } = this;
204
+ this.projectRoot = event.projectRoot;
205
+ this.targets = event.targets;
206
+ this.startedAt = new Date();
207
+ const version = packageVersion(import.meta.url, '../../package.json', '0.0.0');
208
+ this.output.write('');
209
+ this.output.write(`${pc.bold(pc.black(pc.bgCyan(' RUN ')))} ${pc.cyan(`e2e v${version}`)} ${pc.gray(event.projectRoot)}`);
210
+ const details = [`run ${event.runId}`, `targets: ${event.targets.join(', ')}`];
211
+ if (event.ci)
212
+ details.push('CI');
213
+ this.output.write(BADGE_PADDING + pc.dim(details.join(' · ')));
214
+ this.output.write('');
215
+ this.window.start();
216
+ }
217
+ plan(event) {
218
+ for (const planned of event.files) {
219
+ this.group(planned.file, planned.target).planned = planned.tests;
220
+ }
221
+ this.window.redraw();
222
+ }
158
223
  /** Acknowledged immediately, so a bounded teardown is not mistaken for a hang. */
159
224
  runInterrupted(event) {
160
- this.writeAboveStatus(this.pc.yellow(event.mode === 'graceful'
225
+ this.print(this.pc.yellow(event.mode === 'graceful'
161
226
  ? 'interrupted: stopping the running test and tearing down (interrupt again to force)'
162
227
  : 'interrupted again: tearing every worker down now'));
163
228
  }
164
- runStarted(event) {
165
- this.projectRoot = event.projectRoot;
166
- this.output.write(this.pc.dim(`e2e run ${event.runId} (targets: ${event.targets.join(', ')})${event.ci ? ' [CI]' : ''}`));
167
- }
168
- /** A worker began one test-target pair: show it in the live status block. */
229
+ /**
230
+ * A worker began one test-target pair: show it in the live window. A serial
231
+ * member replaces the previous member of its group, which has finished
232
+ * executing even though its result only arrives with the whole group.
233
+ */
169
234
  testStarted(event) {
170
- const key = `${event.testId}@${event.target}`;
171
- const base = `${bounded(event.title)} ${this.pc.dim(`[${event.target}]`)}`;
172
- this.liveBase.set(key, base);
173
- this.status.start(key, base);
174
- // A second concurrent pair ends permanent streaming: entries the stream
175
- // had hidden come back as block rows.
176
- if (this.liveBase.size > 1) {
177
- for (const [other, otherBase] of this.liveBase)
178
- this.redrawLive(other, otherBase);
235
+ if (event.serialId !== undefined) {
236
+ for (const [key, test] of this.running) {
237
+ if (test.serialId === event.serialId && test.group.target === event.target) {
238
+ this.running.delete(key);
239
+ }
240
+ }
179
241
  }
242
+ this.running.set(pairKey(event.testId, event.target), {
243
+ group: this.group(event.file, event.target),
244
+ serialId: event.serialId,
245
+ title: bounded(event.title),
246
+ startedMs: Date.now(),
247
+ step: undefined,
248
+ events: [],
249
+ streaming: false,
250
+ });
251
+ this.window.redraw();
180
252
  }
181
253
  /**
182
- * Streams step progress of a running pair. With a single test running, the
183
- * whole story prints permanently and chronologically: a test header, one
184
- * line per step, one line per model or backend call, and a step summary -
185
- * the scrollback of a run reads without `--debug`. With parallel tests the
186
- * stream would interleave, so each pair instead shows its current step and
187
- * latest calls transiently in the live block.
254
+ * Streams step progress of a running pair. With a single test running, its
255
+ * agent steps print permanently and chronologically under a header naming
256
+ * the file and test - the scrollback of a long agentic run reads without
257
+ * `--debug`. Deterministic steps are fast and many, so they only ever show
258
+ * in the live window. With parallel tests the stream would interleave, so
259
+ * each pair instead shows its current step and latest calls transiently in
260
+ * the live window, and finished agent steps print with the test they
261
+ * belong to.
188
262
  */
189
263
  step(event) {
190
- const key = `${event.testId}@${event.target}`;
191
- const base = this.liveBase.get(key);
192
- if (base === undefined)
264
+ const { pc } = this;
265
+ const running = this.running.get(pairKey(event.testId, event.target));
266
+ if (running === undefined)
193
267
  return;
194
268
  const { progress } = event;
195
269
  switch (progress.phase) {
196
270
  case 'start': {
197
- this.liveStep.set(key, `${progress.api} ${stepLabel(progress.label)}`);
198
- this.liveEvents.delete(key);
199
- if (this.liveBase.size === 1)
200
- this.ensureHeader(key, base);
201
- this.redrawLive(key, base);
271
+ running.step = `${progress.api} ${stepLabel(progress.label)}`;
272
+ running.events = [];
273
+ if (progress.kind === 'agent' && this.running.size === 1 && !running.streaming) {
274
+ running.streaming = true;
275
+ const { group } = running;
276
+ group.streamed = true;
277
+ this.print(` ${pc.yellow(F_POINTER)} ${this.badge(group.target)} ${pc.dim(bounded(group.file))}${this.separator}${running.title}`);
278
+ }
279
+ this.window.redraw();
202
280
  break;
203
281
  }
204
282
  case 'event': {
205
283
  const tail = eventTail(progress.event);
206
- if (!this.liveStep.has(key) || tail === undefined)
284
+ if (running.step === undefined || tail === undefined)
207
285
  break;
208
- const recent = this.liveEvents.get(key) ?? [];
209
- recent.push(tail);
210
- this.liveEvents.set(key, recent);
211
- this.redrawLive(key, base);
286
+ running.events.push(tail);
287
+ this.window.redraw();
212
288
  break;
213
289
  }
214
290
  case 'end': {
215
- this.liveStep.delete(key);
216
- this.liveEvents.delete(key);
217
- this.redrawLive(key, base);
218
- if (progress.kind !== 'agent')
291
+ running.step = undefined;
292
+ running.events = [];
293
+ if (progress.kind !== 'agent') {
294
+ this.window.redraw();
219
295
  break;
220
- const glyph = progress.status === 'passed' ? this.pc.green('✓') : this.pc.red('✗');
296
+ }
297
+ const glyph = progress.status === 'passed' ? pc.green(F_CHECK) : pc.red(F_CROSS);
221
298
  const calls = progress.modelCalls > 0
222
299
  ? ` · ${progress.modelCalls} model call${progress.modelCalls === 1 ? '' : 's'}`
223
300
  : '';
224
301
  const outcome = progress.status === 'passed' ? '' : ` ${progress.status}`;
225
- this.writeAboveStatus(` ${glyph} ${this.pc.dim(progress.api)} ${stepLabel(progress.label)} ` +
226
- this.pc.dim(`${formatDuration(progress.durationMs)}${calls}${outcome}`));
302
+ const context = running.streaming ? '' : `${pc.dim(running.title)}${this.separator}`;
303
+ this.print(` ${glyph} ${context}${pc.dim(progress.api)} ${stepLabel(progress.label)} ` +
304
+ pc.dim(`${formatTime(progress.durationMs)}${calls}${outcome}`));
227
305
  break;
228
306
  }
229
307
  }
230
308
  }
231
- /**
232
- * Adds one serial group's model usage to the run totals. Member result
233
- * records intentionally carry no attempts, so the group record is the one
234
- * place their steps exist; summing here counts each member exactly once.
235
- */
309
+ /** Holds a serial group until each of its members' results has read its details. */
236
310
  serialGroup(group) {
237
- for (const attempt of group.attempts) {
238
- for (const member of attempt.members) {
239
- addStepsUsage(this.runAi, member.steps);
240
- }
241
- }
242
- }
243
- /** Writes one permanent line without disturbing the live block. */
244
- writeAboveStatus(line) {
245
- this.status.erase();
246
- this.output.write(line);
247
- this.status.redraw();
311
+ this.pendingSerial.set(group.id, { group, remaining: group.memberTestIds.length });
248
312
  }
249
313
  /**
250
- * Prints the permanent test header once, before its first step line, so
251
- * collapsed step summaries read under the test they belong to.
314
+ * The details behind one result. A serial member's come from its group; a
315
+ * group that never arrived (a stream out of contract) leaves them empty
316
+ * rather than failing the run.
252
317
  */
253
- ensureHeader(key, base) {
254
- if (this.headerPrinted.has(key))
255
- return;
256
- this.headerPrinted.add(key);
257
- this.writeAboveStatus(`${this.pc.dim('▸')} ${base}`);
318
+ detailsOf(result) {
319
+ if (result.serialGroupId === undefined)
320
+ return attemptDetails(result.attempts);
321
+ const pending = this.pendingSerial.get(result.serialGroupId);
322
+ if (pending === undefined)
323
+ return attemptDetails([]);
324
+ pending.remaining -= 1;
325
+ if (pending.remaining <= 0)
326
+ this.pendingSerial.delete(result.serialGroupId);
327
+ return serialMemberDetails(pending.group, result.test.id);
258
328
  }
259
- /**
260
- * Repaints one live entry: only the active step expands, showing its latest
261
- * calls under the spinner line; between steps the entry collapses to the
262
- * counter (its header is already permanent) or, before any step ran, the
263
- * test title. With parallel pairs the title stays as block context.
264
- */
265
- redrawLive(key, base) {
266
- const solo = this.liveBase.size === 1 && this.headerPrinted.has(key);
267
- const step = this.liveStep.get(key);
268
- if (step === undefined) {
269
- this.status.start(key, solo ? undefined : base);
329
+ testFinished(result) {
330
+ // Unselected pairs are report-only: they never print and the plan never
331
+ // counted them.
332
+ if (!result.selected)
270
333
  return;
334
+ this.running.delete(pairKey(result.test.id, result.target.name));
335
+ const group = this.group(result.test.file, result.target.name);
336
+ const { durationMs, usage, error } = this.detailsOf(result);
337
+ addUsage(this.runUsage, usage);
338
+ const title = bounded(result.test.titlePath.join(' > '));
339
+ group.lines.push({
340
+ title,
341
+ declarationIndex: result.test.declarationIndex,
342
+ status: result.status,
343
+ durationMs,
344
+ usage,
345
+ firstErrorLine: error === undefined ? undefined : bounded(error.message).split('\n')[0],
346
+ skipReason: result.skip === undefined ? undefined : bounded(result.skip.reason),
347
+ });
348
+ if (statusBucket(result.status) === 'failed') {
349
+ this.failures.push({ group, title, status: result.status, error });
271
350
  }
272
- const head = solo ? this.pc.dim(step) : `${base}\n ${this.pc.dim(`▸ ${step}`)}`;
273
- const indent = solo ? ' ' : ' ';
274
- const lines = [head];
275
- // Every call of the active step stays visible until the step collapses.
276
- // The block must still fit the screen: repainting more rows than the
277
- // terminal has breaks the cursor-up erase, so the oldest calls fold into
278
- // one counter line when height runs out.
279
- const events = this.liveEvents.get(key) ?? [];
280
- const maxEvents = Math.max(4, (process.stdout.rows ?? 40) - 8);
281
- const overflow = events.length - maxEvents;
282
- const shown = overflow > 0 ? events.slice(overflow) : events;
283
- if (overflow > 0) {
284
- lines.push(`${indent}${this.pc.dim(`… ${overflow} earlier call${overflow === 1 ? '' : 's'}`)}`);
285
- }
286
- for (const tail of shown) {
287
- lines.push(`${indent}${this.pc.dim(tail)}`);
351
+ if (group.planned !== undefined && group.lines.length >= group.planned)
352
+ this.printGroup(group);
353
+ this.window.redraw();
354
+ }
355
+ /** Counters over every reported result; the total is the plan's once it has arrived. */
356
+ testCounters() {
357
+ const counters = tally([...this.groups.values()].flatMap((group) => group.lines));
358
+ counters.total = 0;
359
+ for (const group of this.groups.values())
360
+ counters.total += group.planned ?? group.lines.length;
361
+ return counters;
362
+ }
363
+ /** Counters over test files; a file lands in an outcome once its block has printed. */
364
+ fileCounters() {
365
+ const counters = emptyCounters();
366
+ for (const group of this.groups.values()) {
367
+ counters.total += 1;
368
+ if (group.printed)
369
+ counters[fileOutcome(tally(group.lines))] += 1;
288
370
  }
289
- this.status.start(key, lines.join('\n'));
371
+ return counters;
290
372
  }
291
- testFinished(result) {
292
- if (!result.selected && result.status === 'skipped') {
293
- this.status.skip();
373
+ /**
374
+ * Prints one file's block: the file line with its counts, then - when the
375
+ * file failed, had a flaky pass, streamed its steps, or is the run's only
376
+ * file - one line per test, as vitest lists tests for a failed module.
377
+ */
378
+ printGroup(group) {
379
+ if (group.printed)
380
+ return;
381
+ group.printed = true;
382
+ const { pc } = this;
383
+ const counts = tally(group.lines);
384
+ const outcome = fileOutcome(counts);
385
+ const symbol = outcome === 'failed'
386
+ ? pc.red(F_POINTER)
387
+ : outcome === 'skipped'
388
+ ? pc.dim(pc.gray(F_DOWN))
389
+ : pc.green(F_CHECK);
390
+ const state = [
391
+ pc.dim(`${counts.total} test${counts.total === 1 ? '' : 's'}`),
392
+ counts.failed > 0 ? pc.red(`${counts.failed} failed`) : undefined,
393
+ counts.flaky > 0 ? pc.yellow(`${counts.flaky} flaky`) : undefined,
394
+ counts.skipped > 0 ? pc.yellow(`${counts.skipped} skipped`) : undefined,
395
+ ]
396
+ .filter((part) => part !== undefined)
397
+ .join(pc.dim(' | '));
398
+ const durationMs = group.lines.reduce((total, line) => total + line.durationMs, 0);
399
+ const ai = aiSegment(sumUsage(group.lines));
400
+ const parts = [
401
+ ` ${symbol} ${this.badge(group.target)} ${bounded(group.file)}`,
402
+ `${pc.dim('(')}${state}${pc.dim(')')}`,
403
+ ];
404
+ // A file whose tests all skipped never ran; `0ms` would only invite a question.
405
+ if (durationMs > 0)
406
+ parts.push(pc.dim(formatTime(durationMs)));
407
+ if (ai !== undefined)
408
+ parts.push(pc.dim(ai));
409
+ this.print(parts.join(' '));
410
+ const verbose = counts.failed > 0 ||
411
+ counts.flaky > 0 ||
412
+ group.streamed ||
413
+ this.groups.size === 1;
414
+ if (!verbose)
294
415
  return;
416
+ const ordered = group.lines.toSorted((a, b) => a.declarationIndex - b.declarationIndex);
417
+ for (const line of ordered) {
418
+ for (const rendered of this.testLine(line))
419
+ this.print(rendered);
295
420
  }
296
- this.status.erase();
297
- const key = `${result.test.id}@${result.target.name}`;
298
- this.status.finish(key);
299
- this.liveBase.delete(key);
300
- this.liveStep.delete(key);
301
- this.liveEvents.delete(key);
302
- this.headerPrinted.delete(key);
303
- const title = bounded(result.test.titlePath.join(' \u203a '));
304
- const target = result.target.name;
305
- const duration = result.attempts.reduce((total, attempt) => total + attempt.durationMs, 0);
306
- const usage = aiUsage(result);
307
- this.runAi.calls += usage.calls;
308
- this.runAi.tokens += usage.tokens;
309
- if (usage.costUsd !== undefined)
310
- this.runAi.costUsd = (this.runAi.costUsd ?? 0) + usage.costUsd;
311
- const ai = aiSegment(usage);
312
- const aiSuffix = ai === undefined ? '' : ` \u00b7 ${ai}`;
313
- switch (result.status) {
421
+ }
422
+ /** One test row under its file line, plus the first error line for a failure. */
423
+ testLine(line) {
424
+ const { pc } = this;
425
+ const duration = pc.dim(formatTime(line.durationMs));
426
+ const segment = aiSegment(line.usage);
427
+ const ai = segment === undefined ? '' : ` ${pc.dim(segment)}`;
428
+ switch (line.status) {
314
429
  case 'passed':
315
- this.passed += 1;
316
- this.output.write(`${this.pc.green('\u2713')} ${title} ${this.pc.dim(`[${target}] ${formatDuration(duration)}${aiSuffix}`)}`);
317
- break;
430
+ return [` ${pc.green(F_CHECK)} ${line.title} ${duration}${ai}`];
318
431
  case 'flaky':
319
- this.flaky += 1;
320
- this.output.write(`${this.pc.yellow('\u2713')} ${title} ${this.pc.yellow('(flaky)')} ${this.pc.dim(`[${target}] ${formatDuration(duration)}${aiSuffix}`)}`);
321
- break;
322
- case 'skipped':
323
- this.skipped += 1;
324
- this.output.write(`${this.pc.cyan('-')} ${title} ${this.pc.dim(`[${target}] skipped: ${bounded(result.skip?.reason ?? '')}`)}`);
325
- break;
432
+ return [` ${pc.yellow(F_CHECK)} ${line.title} ${pc.yellow('(flaky)')} ${duration}${ai}`];
433
+ case 'skipped': {
434
+ // `test.skip` without a message records the bare word; repeating it adds nothing.
435
+ const reason = line.skipReason === undefined || line.skipReason === 'skipped'
436
+ ? ''
437
+ : pc.dim(pc.gray(` [${line.skipReason}]`));
438
+ return [` ${pc.dim(pc.gray(F_DOWN))} ${line.title}${reason}`];
439
+ }
326
440
  default: {
327
- this.failed += 1;
328
- this.output.write(`${this.pc.red('\u2717')} ${title} ${this.pc.dim(`[${target}] ${result.status} ${formatDuration(duration)}${aiSuffix}`)}`);
329
- const error = result.attempts[result.attempts.length - 1]?.error;
330
- if (error !== undefined) {
331
- for (const line of bounded(error.message).split('\n')) {
332
- this.output.write(` ${this.pc.red(line)}`);
333
- }
334
- this.writeFailureLocation(error.stack);
441
+ const status = line.status === 'failed' ? '' : pc.red(` (${line.status})`);
442
+ const rows = [` ${pc.red(`${F_CROSS} ${line.title}`)}${status} ${duration}${ai}`];
443
+ if (line.firstErrorLine !== undefined) {
444
+ // A glance line; the `Failed Tests` section carries the whole message.
445
+ const glance = ellipsize(line.firstErrorLine, terminalColumns() - ERROR_GLANCE_INDENT);
446
+ rows.push(` ${pc.red(`${F_RIGHT} ${glance}`)}`);
335
447
  }
448
+ return rows;
336
449
  }
337
450
  }
338
- this.status.redraw();
339
451
  }
340
- /** Names the user's failing line and renders a small code frame around it. */
341
- writeFailureLocation(stack) {
342
- if (this.projectRoot === undefined)
452
+ /**
453
+ * vitest's padded summary, shared by the live window and the final report:
454
+ * files, tests, model usage, run errors, start time, and elapsed time.
455
+ */
456
+ summaryRows() {
457
+ const { pc } = this;
458
+ const files = this.fileCounters();
459
+ const tests = this.testCounters();
460
+ const rows = [
461
+ padTitle(pc, 'Test Files') + (files.total === 0 ? pc.dim('no test files') : stateString(pc, files)),
462
+ padTitle(pc, 'Tests') + (tests.total === 0 ? pc.dim('no tests executed') : stateString(pc, tests)),
463
+ ];
464
+ const ai = aiSegment(this.runUsage);
465
+ if (ai !== undefined)
466
+ rows.push(padTitle(pc, 'AI') + `${ai} · ${this.runUsage.calls} model calls`);
467
+ if (this.errors.length > 0) {
468
+ const count = this.errors.length;
469
+ rows.push(padTitle(pc, 'Errors') + pc.bold(pc.red(`${count} error${count === 1 ? '' : 's'}`)));
470
+ }
471
+ rows.push(padTitle(pc, 'Start at') + formatClock(this.startedAt));
472
+ rows.push(padTitle(pc, 'Duration') + formatTime(Date.now() - this.startedAt.getTime()));
473
+ return rows;
474
+ }
475
+ /**
476
+ * The live window: running files and tests, then the summary. The block
477
+ * must fit the screen, because repainting more rows than the terminal has
478
+ * breaks the cursor-up erase: rows left after the summary go to the running
479
+ * tests, each test's calls share what remains once every test has its own
480
+ * line, and tests that still do not fit fold into one `more running` marker.
481
+ */
482
+ renderWindow() {
483
+ const { pc } = this;
484
+ const now = Date.now();
485
+ const active = new Map();
486
+ for (const test of this.running.values()) {
487
+ const tests = active.get(test.group);
488
+ if (tests === undefined)
489
+ active.set(test.group, [test]);
490
+ else
491
+ tests.push(test);
492
+ }
493
+ const summary = this.summaryRows();
494
+ let budget = terminalRows() - summary.length - WINDOW_CHROME_ROWS;
495
+ const spare = budget - active.size - this.running.size * WINDOW_ROWS_PER_TEST;
496
+ const maxEvents = Math.max(0, Math.floor(spare / Math.max(1, this.running.size)));
497
+ const lines = [''];
498
+ let hidden = 0;
499
+ for (const [group, tests] of active) {
500
+ if (budget < 2) {
501
+ hidden += tests.length;
502
+ continue;
503
+ }
504
+ const progress = pc.dim(` ${group.lines.length}/${group.planned ?? '?'}`);
505
+ lines.push(`${pc.bold(pc.yellow(` ${F_POINTER} `))}${this.badge(group.target)} ${bounded(group.file)}${progress}`);
506
+ budget -= 1;
507
+ tests.forEach((test, index) => {
508
+ if (budget < 1) {
509
+ hidden += 1;
510
+ return;
511
+ }
512
+ const glyph = index === tests.length - 1 ? F_TREE_END : F_TREE_MIDDLE;
513
+ const elapsed = pc.bold(pc.yellow(formatTime(Math.max(0, now - test.startedMs))));
514
+ lines.push(`${pc.bold(pc.yellow(` ${glyph} `))}${test.title} ${elapsed}`);
515
+ budget -= 1;
516
+ if (test.step === undefined)
517
+ return;
518
+ const detail = [` ${pc.dim(`${F_DOWN_RIGHT} ${test.step}`)}`];
519
+ const overflow = test.events.length - maxEvents;
520
+ if (overflow > 0) {
521
+ detail.push(` ${pc.dim(`… ${overflow} earlier call${overflow === 1 ? '' : 's'}`)}`);
522
+ }
523
+ for (const tail of overflow > 0 ? test.events.slice(overflow) : test.events) {
524
+ detail.push(` ${pc.dim(tail)}`);
525
+ }
526
+ const shown = detail.slice(0, budget);
527
+ lines.push(...shown);
528
+ budget -= shown.length;
529
+ });
530
+ }
531
+ if (hidden > 0)
532
+ lines.push(pc.dim(` … ${hidden} more running`));
533
+ if (active.size > 0)
534
+ lines.push('');
535
+ lines.push(...summary, '');
536
+ return lines;
537
+ }
538
+ /** vitest's `Failed Tests` section: a banner, then each failure with its code frame. */
539
+ printFailures() {
540
+ const { pc } = this;
541
+ if (this.failures.length === 0)
343
542
  return;
543
+ this.print('');
544
+ this.print(this.errorBanner(`Failed Tests ${this.failures.length}`));
545
+ this.print('');
546
+ this.failures.forEach(({ group, title, status, error }, index) => {
547
+ this.print(`${pc.bold(pc.bgRed(' FAIL '))} ${this.badge(group.target)} ${bounded(group.file)}${this.separator}${title}`);
548
+ if (error === undefined) {
549
+ this.print(pc.red(`${pc.bold(status)}: no error was recorded`));
550
+ }
551
+ else {
552
+ const [first = '', ...rest] = bounded(error.message).split('\n');
553
+ this.print(pc.red(`${pc.bold(bounded(error.code))}: ${first}`));
554
+ for (const line of rest)
555
+ this.print(pc.red(line));
556
+ this.printFailureLocation(error.stack);
557
+ }
558
+ const marker = `[${index + 1}/${this.failures.length}]`;
559
+ const { before, after } = rule(marker, 'right');
560
+ this.print('');
561
+ this.print(pc.red(pc.dim(`${before}${marker}${after}`)));
562
+ this.print('');
563
+ });
564
+ }
565
+ /** A full-width red rule with a centered `FAIL`-style label. */
566
+ errorBanner(message) {
567
+ const { pc } = this;
568
+ const label = pc.bold(pc.bgRed(` ${message} `));
569
+ const { before, after } = rule(label, 'center');
570
+ return `${pc.red(before)}${label}${pc.red(after)}`;
571
+ }
572
+ /** Names the user's failing line and renders a code frame around it. */
573
+ printFailureLocation(stack) {
574
+ const { pc } = this;
344
575
  const frame = userFrame(stack, this.projectRoot);
345
576
  if (frame === undefined)
346
577
  return;
347
- const relative = path.relative(this.projectRoot, frame.file);
348
- this.output.write('');
349
- this.output.write(` ${this.pc.dim('at')} ${this.pc.cyan(`${bounded(relative)}:${frame.line}:${frame.column}`)}`);
350
- for (const line of codeFrame(frame))
351
- this.output.write(` ${line}`);
578
+ this.print(pc.cyan(` ${pc.dim(F_POINTER)} ${bounded(this.displayPath(frame.file))}:${pc.dim(`${frame.line}:${frame.column}`)}`));
579
+ for (const line of codeFrame(frame, pc))
580
+ this.print(` ${line}`);
352
581
  }
353
- runFinished(event) {
354
- this.status.stop();
355
- // Run-level errors never arrive as results: they abort before, between, or
356
- // after test execution. Without this the console shows only a bare exit
357
- // code and the reason lives solely in report.json.
582
+ /**
583
+ * Run-level errors never arrive as results: they abort before, between, or
584
+ * after test execution. Without this the console shows only a bare exit
585
+ * code and the reason lives solely in report.json.
586
+ */
587
+ printErrors() {
588
+ const { pc } = this;
589
+ if (this.errors.length === 0)
590
+ return;
591
+ this.print('');
592
+ this.print(this.errorBanner(`Run Errors ${this.errors.length}`));
593
+ this.print('');
358
594
  for (const error of this.errors) {
359
- this.output.write('');
360
- const phase = error.phase === undefined ? '' : ` ${this.pc.dim(`(${error.phase})`)}`;
361
- this.output.write(`${this.pc.red(`\u2717 ${error.category} error`)} ${this.pc.dim(error.code)}${phase}`);
362
- for (const line of bounded(error.message).split('\n')) {
363
- this.output.write(` ${this.pc.red(line)}`);
364
- }
595
+ const phase = error.phase === undefined ? '' : pc.dim(` (${bounded(error.phase)})`);
596
+ this.print(`${pc.bold(pc.bgRed(' ERROR '))} ${bounded(error.category)} error ${pc.dim(bounded(error.code))}${phase}`);
597
+ for (const line of bounded(error.message).split('\n'))
598
+ this.print(pc.red(line));
599
+ this.print('');
365
600
  }
366
- const parts = [
367
- this.passed > 0 ? this.pc.green(`${this.passed} passed`) : undefined,
368
- this.failed > 0 ? this.pc.red(`${this.failed} failed`) : undefined,
369
- this.flaky > 0 ? this.pc.yellow(`${this.flaky} flaky`) : undefined,
370
- this.skipped > 0 ? this.pc.cyan(`${this.skipped} skipped`) : undefined,
371
- ].filter((part) => part !== undefined);
372
- this.output.write('');
373
- this.output.write(parts.length > 0 ? parts.join(this.pc.dim(' \u00b7 ')) : this.pc.dim('no tests executed'));
374
- const ai = aiSegment(this.runAi);
375
- if (ai !== undefined) {
376
- this.output.write(this.pc.dim(`${ai} \u00b7 ${this.runAi.calls} model calls`));
601
+ }
602
+ runFinished(event) {
603
+ const { pc } = this;
604
+ this.window.stop();
605
+ // An interrupted or crashed run leaves files without their full result
606
+ // set; print what they have so nothing that ran goes unreported.
607
+ for (const group of this.groups.values()) {
608
+ if (!group.printed && group.lines.length > 0)
609
+ this.printGroup(group);
377
610
  }
378
- this.output.write(this.pc.dim(`report: ${event.reportPath ?? '(not written)'}`));
611
+ this.printFailures();
612
+ this.printErrors();
613
+ this.print('');
614
+ for (const row of this.summaryRows())
615
+ this.print(row);
616
+ this.print(padTitle(pc, 'Report') +
617
+ (event.reportPath === undefined ? pc.dim('(not written)') : this.displayPath(event.reportPath)));
379
618
  if (event.junitPath !== undefined) {
380
- this.output.write(this.pc.dim(`junit: ${event.junitPath}`));
619
+ this.print(padTitle(pc, 'JUnit') + this.displayPath(event.junitPath));
381
620
  }
382
621
  if (event.aiTracePath !== undefined) {
383
- this.output.write(this.pc.dim(`ai trace: ${event.aiTracePath} · open with: npx unbox-ai ${event.aiTracePath}`));
622
+ const shown = this.displayPath(event.aiTracePath);
623
+ this.print(padTitle(pc, 'AI trace') + `${shown} ${pc.dim(`(open with: npx unbox-ai ${shown})`)}`);
384
624
  }
625
+ this.print('');
385
626
  }
386
627
  }
387
628
  //# sourceMappingURL=list.js.map