@vitest-agent/reporter 1.0.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/LICENSE +21 -0
- package/LiveInkRenderer.js +119 -0
- package/README.md +61 -0
- package/defaultReporter.js +208 -0
- package/index.d.ts +1010 -0
- package/index.js +18 -0
- package/package.json +72 -0
- package/tsdoc-metadata.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1010 @@
|
|
|
1
|
+
import { PubSub, Schema } from "effect";
|
|
2
|
+
//#region ../sdk/dist/dev/pkg/DataReader-2kJ9I9Hh.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Per-file coverage data including uncovered line ranges.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
declare const FileCoverageReport: Schema.Struct<{
|
|
8
|
+
file: typeof Schema.String;
|
|
9
|
+
summary: Schema.Struct<{
|
|
10
|
+
statements: typeof Schema.Number;
|
|
11
|
+
branches: typeof Schema.Number;
|
|
12
|
+
functions: typeof Schema.Number;
|
|
13
|
+
lines: typeof Schema.Number;
|
|
14
|
+
}>;
|
|
15
|
+
uncoveredLines: typeof Schema.String;
|
|
16
|
+
}>;
|
|
17
|
+
/** @public */
|
|
18
|
+
type FileCoverageReport = typeof FileCoverageReport.Type;
|
|
19
|
+
/**
|
|
20
|
+
* Complete coverage report attached to an AgentReport.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Complete per-project test report written to disk as JSON.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
declare const AgentReport: Schema.Struct<{
|
|
28
|
+
timestamp: typeof Schema.String;
|
|
29
|
+
project: Schema.optional<typeof Schema.String>;
|
|
30
|
+
reason: Schema.Literal<["passed", "failed", "interrupted"]>;
|
|
31
|
+
summary: Schema.Struct<{
|
|
32
|
+
total: typeof Schema.Number;
|
|
33
|
+
passed: typeof Schema.Number;
|
|
34
|
+
failed: typeof Schema.Number;
|
|
35
|
+
skipped: typeof Schema.Number;
|
|
36
|
+
duration: typeof Schema.Number;
|
|
37
|
+
}>;
|
|
38
|
+
failed: Schema.Array$<Schema.Struct<{
|
|
39
|
+
file: typeof Schema.String;
|
|
40
|
+
state: Schema.Literal<["passed", "failed", "skipped", "pending"]>;
|
|
41
|
+
duration: Schema.optional<typeof Schema.Number>;
|
|
42
|
+
errors: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
43
|
+
message: typeof Schema.String;
|
|
44
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
45
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
46
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
47
|
+
received: Schema.optional<typeof Schema.String>;
|
|
48
|
+
}>>>;
|
|
49
|
+
tests: Schema.Array$<Schema.Struct<{
|
|
50
|
+
name: typeof Schema.String;
|
|
51
|
+
fullName: typeof Schema.String;
|
|
52
|
+
state: Schema.Literal<["passed", "failed", "skipped", "pending"]>;
|
|
53
|
+
duration: Schema.optional<typeof Schema.Number>;
|
|
54
|
+
flaky: Schema.optional<typeof Schema.Boolean>;
|
|
55
|
+
slow: Schema.optional<typeof Schema.Boolean>;
|
|
56
|
+
errors: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
57
|
+
message: typeof Schema.String;
|
|
58
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
59
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
60
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
61
|
+
received: Schema.optional<typeof Schema.String>;
|
|
62
|
+
}>>>;
|
|
63
|
+
classification: Schema.optional<Schema.Literal<["stable", "new-failure", "persistent", "flaky", "recovered"]>>;
|
|
64
|
+
}>>;
|
|
65
|
+
}>>;
|
|
66
|
+
unhandledErrors: Schema.Array$<Schema.Struct<{
|
|
67
|
+
message: typeof Schema.String;
|
|
68
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
69
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
70
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
71
|
+
received: Schema.optional<typeof Schema.String>;
|
|
72
|
+
}>>;
|
|
73
|
+
failedFiles: Schema.Array$<typeof Schema.String>;
|
|
74
|
+
coverage: Schema.optional<Schema.Struct<{
|
|
75
|
+
totals: Schema.Struct<{
|
|
76
|
+
statements: typeof Schema.Number;
|
|
77
|
+
branches: typeof Schema.Number;
|
|
78
|
+
functions: typeof Schema.Number;
|
|
79
|
+
lines: typeof Schema.Number;
|
|
80
|
+
}>;
|
|
81
|
+
thresholds: Schema.Struct<{
|
|
82
|
+
global: Schema.Struct<{
|
|
83
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
84
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
85
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
86
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
87
|
+
}>;
|
|
88
|
+
patterns: Schema.optionalWith<Schema.Array$<Schema.Tuple2<typeof Schema.String, Schema.Struct<{
|
|
89
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
90
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
91
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
92
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
93
|
+
}>>>, {
|
|
94
|
+
default: () => never[];
|
|
95
|
+
}>;
|
|
96
|
+
}>;
|
|
97
|
+
targets: Schema.optional<Schema.Struct<{
|
|
98
|
+
global: Schema.Struct<{
|
|
99
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
100
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
101
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
102
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
103
|
+
}>;
|
|
104
|
+
patterns: Schema.optionalWith<Schema.Array$<Schema.Tuple2<typeof Schema.String, Schema.Struct<{
|
|
105
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
106
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
107
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
108
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
109
|
+
}>>>, {
|
|
110
|
+
default: () => never[];
|
|
111
|
+
}>;
|
|
112
|
+
}>>;
|
|
113
|
+
baselines: Schema.optional<Schema.Struct<{
|
|
114
|
+
global: Schema.Struct<{
|
|
115
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
116
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
117
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
118
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
119
|
+
}>;
|
|
120
|
+
patterns: Schema.optionalWith<Schema.Array$<Schema.Tuple2<typeof Schema.String, Schema.Struct<{
|
|
121
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
122
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
123
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
124
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
125
|
+
}>>>, {
|
|
126
|
+
default: () => never[];
|
|
127
|
+
}>;
|
|
128
|
+
}>>;
|
|
129
|
+
scoped: Schema.optionalWith<typeof Schema.Boolean, {
|
|
130
|
+
default: () => false;
|
|
131
|
+
}>;
|
|
132
|
+
scopedFiles: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
133
|
+
lowCoverage: Schema.Array$<Schema.Struct<{
|
|
134
|
+
file: typeof Schema.String;
|
|
135
|
+
summary: Schema.Struct<{
|
|
136
|
+
statements: typeof Schema.Number;
|
|
137
|
+
branches: typeof Schema.Number;
|
|
138
|
+
functions: typeof Schema.Number;
|
|
139
|
+
lines: typeof Schema.Number;
|
|
140
|
+
}>;
|
|
141
|
+
uncoveredLines: typeof Schema.String;
|
|
142
|
+
}>>;
|
|
143
|
+
lowCoverageFiles: Schema.Array$<typeof Schema.String>;
|
|
144
|
+
belowTarget: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
145
|
+
file: typeof Schema.String;
|
|
146
|
+
summary: Schema.Struct<{
|
|
147
|
+
statements: typeof Schema.Number;
|
|
148
|
+
branches: typeof Schema.Number;
|
|
149
|
+
functions: typeof Schema.Number;
|
|
150
|
+
lines: typeof Schema.Number;
|
|
151
|
+
}>;
|
|
152
|
+
uncoveredLines: typeof Schema.String;
|
|
153
|
+
}>>>;
|
|
154
|
+
belowTargetFiles: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
155
|
+
}>>;
|
|
156
|
+
tagCounts: Schema.optional<Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
157
|
+
passed: Schema.optional<typeof Schema.Number>;
|
|
158
|
+
failed: Schema.optional<typeof Schema.Number>;
|
|
159
|
+
skipped: Schema.optional<typeof Schema.Number>;
|
|
160
|
+
}>>>;
|
|
161
|
+
}>;
|
|
162
|
+
/** @public */
|
|
163
|
+
type AgentReport = typeof AgentReport.Type; //#endregion
|
|
164
|
+
//#region src/schemas/Identity.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* Canonical UUID for an LLM agent invocation. Generated server-side at
|
|
167
|
+
* `register_agent` time. Stable across transport reconnects within an
|
|
168
|
+
* agent's lifetime.
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region ../sdk/dist/dev/pkg/index.d.ts
|
|
173
|
+
/**
|
|
174
|
+
* The renderer state. Both the human (Ink) and agent (string)
|
|
175
|
+
* renderers read this shape; the reducer is the only producer.
|
|
176
|
+
*
|
|
177
|
+
* `phase` is the layout discriminator — agent mode emits one final
|
|
178
|
+
* frame when `phase === "finished"`; human mode redraws at every
|
|
179
|
+
* state change. `"timed-out"` is a terminal phase like `"finished"`
|
|
180
|
+
* — the run is over, but it ended because `onProcessTimeout` fired
|
|
181
|
+
* rather than the suite completing.
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
declare const RenderState: Schema.Struct<{
|
|
185
|
+
phase: Schema.Literal<["idle", "running", "finished", "timed-out"]>;
|
|
186
|
+
runId: Schema.NullOr<typeof Schema.String>;
|
|
187
|
+
configHash: Schema.NullOr<typeof Schema.String>;
|
|
188
|
+
startedAt: Schema.NullOr<typeof Schema.String>;
|
|
189
|
+
finishedAt: Schema.NullOr<typeof Schema.String>;
|
|
190
|
+
modules: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
191
|
+
modulePath: typeof Schema.String;
|
|
192
|
+
status: Schema.Literal<["queued", "running", "finished"]>;
|
|
193
|
+
passCount: typeof Schema.Number;
|
|
194
|
+
failCount: typeof Schema.Number;
|
|
195
|
+
skipCount: typeof Schema.Number;
|
|
196
|
+
timeoutCount: typeof Schema.Number;
|
|
197
|
+
durationMs: typeof Schema.Number;
|
|
198
|
+
tests: Schema.Array$<Schema.Struct<{
|
|
199
|
+
testName: typeof Schema.String;
|
|
200
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
201
|
+
status: Schema.Union<[Schema.Literal<["passed", "failed", "skipped", "pending"]>, Schema.Literal<["running", "timed-out"]>]>;
|
|
202
|
+
durationMs: Schema.NullOr<typeof Schema.Number>;
|
|
203
|
+
error: Schema.optional<Schema.Struct<{
|
|
204
|
+
message: typeof Schema.String;
|
|
205
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
206
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
207
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
208
|
+
received: Schema.optional<typeof Schema.String>;
|
|
209
|
+
}>>;
|
|
210
|
+
}>>;
|
|
211
|
+
/**
|
|
212
|
+
* Owning Vitest project name. Optional — events from project-less
|
|
213
|
+
* configs or older replays leave it `undefined`, which the renderer
|
|
214
|
+
* treats as a single anonymous project.
|
|
215
|
+
*/
|
|
216
|
+
projectName: Schema.optional<typeof Schema.String>;
|
|
217
|
+
/**
|
|
218
|
+
* ISO wall-clock stamp captured at `onTestModuleStart`. The live
|
|
219
|
+
* renderer derives a ticking elapsed column from it while the module
|
|
220
|
+
* runs; once finished it shows `durationMs` instead. Optional — a
|
|
221
|
+
* module seeded by `ModuleQueued` (or replayed) has no start stamp.
|
|
222
|
+
*/
|
|
223
|
+
startedAt: Schema.optional<typeof Schema.String>;
|
|
224
|
+
tagCounts: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Number>>;
|
|
225
|
+
}>>;
|
|
226
|
+
moduleOrder: Schema.Array$<typeof Schema.String>;
|
|
227
|
+
totals: Schema.Struct<{
|
|
228
|
+
passCount: typeof Schema.Number;
|
|
229
|
+
failCount: typeof Schema.Number;
|
|
230
|
+
skipCount: typeof Schema.Number;
|
|
231
|
+
timeoutCount: typeof Schema.Number;
|
|
232
|
+
durationMs: typeof Schema.Number;
|
|
233
|
+
}>;
|
|
234
|
+
coverage: Schema.NullOr<Schema.Struct<{
|
|
235
|
+
metrics: Schema.Struct<{
|
|
236
|
+
statements: typeof Schema.Number;
|
|
237
|
+
branches: typeof Schema.Number;
|
|
238
|
+
functions: typeof Schema.Number;
|
|
239
|
+
lines: typeof Schema.Number;
|
|
240
|
+
}>;
|
|
241
|
+
thresholds: Schema.Struct<{
|
|
242
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
243
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
244
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
245
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
246
|
+
}>;
|
|
247
|
+
gaps: Schema.Array$<Schema.Struct<{
|
|
248
|
+
file: typeof Schema.String;
|
|
249
|
+
missing: Schema.Struct<{
|
|
250
|
+
statements: typeof Schema.Number;
|
|
251
|
+
branches: typeof Schema.Number;
|
|
252
|
+
functions: typeof Schema.Number;
|
|
253
|
+
lines: typeof Schema.Number;
|
|
254
|
+
}>;
|
|
255
|
+
uncoveredLines: Schema.optional<typeof Schema.String>;
|
|
256
|
+
}>>;
|
|
257
|
+
violations: Schema.Array$<Schema.Struct<{
|
|
258
|
+
metric: Schema.Literal<["lines", "branches", "functions", "statements"]>;
|
|
259
|
+
expected: typeof Schema.Number;
|
|
260
|
+
actual: typeof Schema.Number;
|
|
261
|
+
}>>;
|
|
262
|
+
}>>;
|
|
263
|
+
trend: Schema.NullOr<Schema.Struct<{
|
|
264
|
+
direction: Schema.Literal<["improving", "regressing", "stable"]>;
|
|
265
|
+
runCount: typeof Schema.Number;
|
|
266
|
+
}>>;
|
|
267
|
+
failures: Schema.Array$<Schema.Struct<{
|
|
268
|
+
modulePath: typeof Schema.String;
|
|
269
|
+
testName: typeof Schema.String;
|
|
270
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
271
|
+
error: Schema.optional<Schema.Struct<{
|
|
272
|
+
message: typeof Schema.String;
|
|
273
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
274
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
275
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
276
|
+
received: Schema.optional<typeof Schema.String>;
|
|
277
|
+
}>>;
|
|
278
|
+
timedOut: Schema.optional<typeof Schema.Boolean>;
|
|
279
|
+
classification: Schema.NullOr<Schema.Literal<["stable", "new-failure", "persistent", "flaky", "recovered"]>>;
|
|
280
|
+
}>>;
|
|
281
|
+
suggestedActions: Schema.Array$<Schema.Struct<{
|
|
282
|
+
severity: Schema.Literal<["info", "warn", "blocker"]>;
|
|
283
|
+
title: typeof Schema.String;
|
|
284
|
+
detail: typeof Schema.String;
|
|
285
|
+
targetTool: Schema.optional<typeof Schema.String>;
|
|
286
|
+
}>>;
|
|
287
|
+
}>;
|
|
288
|
+
/** @public */
|
|
289
|
+
type RenderState = typeof RenderState.Type;
|
|
290
|
+
/**
|
|
291
|
+
* Initial state — what the reducer returns when no events have been
|
|
292
|
+
* applied yet. Exported so tests and the renderers' bootstrapping
|
|
293
|
+
* code share one definition.
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/contracts/dispatcher.d.ts
|
|
298
|
+
/**
|
|
299
|
+
* The four run shapes the dispatcher distinguishes.
|
|
300
|
+
*
|
|
301
|
+
* Computed once per run from the reduced state's module count, the
|
|
302
|
+
* distinct-project count (carried via {@link DispatchInputs.projects}),
|
|
303
|
+
* and the test count inside each module.
|
|
304
|
+
*
|
|
305
|
+
* - `single-test` — exactly one test by name across the run.
|
|
306
|
+
* - `single-file` — exactly one module, more than one test.
|
|
307
|
+
* - `single-project` — one project, more than one module.
|
|
308
|
+
* - `workspace` — more than one project.
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
type RunShape = "single-test" | "single-file" | "single-project" | "workspace";
|
|
312
|
+
/**
|
|
313
|
+
* The three outcome classes the dispatcher distinguishes.
|
|
314
|
+
*
|
|
315
|
+
* - `all-pass` — `totals.failed === 0` and no coverage threshold violations.
|
|
316
|
+
* - `some-fail` — `totals.failed > 0`.
|
|
317
|
+
* - `threshold-violation` — `totals.failed === 0` and at least one coverage violation.
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
type RunOutcome = "all-pass" | "some-fail" | "threshold-violation";
|
|
321
|
+
/**
|
|
322
|
+
* Compact per-project aggregate carried into workspace cells.
|
|
323
|
+
*
|
|
324
|
+
* Populated by the plugin from `ReporterRenderInput.reports`. Empty for
|
|
325
|
+
* non-workspace shapes. `tagCounts`, `belowTarget`, and `violations` are
|
|
326
|
+
* optional — workspace cells render the columns only when present.
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
329
|
+
interface ProjectSummary {
|
|
330
|
+
readonly name: string;
|
|
331
|
+
readonly passCount: number;
|
|
332
|
+
readonly failCount: number;
|
|
333
|
+
readonly skipCount: number;
|
|
334
|
+
readonly durationMs: number;
|
|
335
|
+
readonly tagCounts?: Record<string, number>;
|
|
336
|
+
readonly belowTarget?: number;
|
|
337
|
+
readonly violations?: number;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Per-run trend direction handed to cells that surface a `Trend: …` line.
|
|
341
|
+
*
|
|
342
|
+
* Mirrors the inline `ReporterRenderInput.trendSummary` shape — promoted
|
|
343
|
+
* to a named type here so the dispatcher and its cells can pass it around
|
|
344
|
+
* without re-declaring it. The plugin populates this from
|
|
345
|
+
* `ReporterRenderInput.trendSummary` before invoking `dispatch`.
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
interface TrendSummary {
|
|
349
|
+
readonly direction: "improving" | "regressing" | "stable";
|
|
350
|
+
readonly runCount: number;
|
|
351
|
+
readonly firstMetric?: {
|
|
352
|
+
readonly name: string;
|
|
353
|
+
readonly from: number;
|
|
354
|
+
readonly to: number;
|
|
355
|
+
readonly target?: number;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Inputs each cell renderer reads to produce its output.
|
|
360
|
+
*
|
|
361
|
+
* `state` carries the post-reduce projection of the `RunEvent`
|
|
362
|
+
* stream. `shape` and `outcome` are the classified axes the dispatcher
|
|
363
|
+
* keyed on to reach this cell. The remaining fields are non-state
|
|
364
|
+
* helpers the plugin computes once before dispatch so cells stay pure.
|
|
365
|
+
* @public
|
|
366
|
+
*/
|
|
367
|
+
interface DispatchInputs {
|
|
368
|
+
readonly state: RenderState;
|
|
369
|
+
readonly shape: RunShape;
|
|
370
|
+
readonly outcome: RunOutcome;
|
|
371
|
+
/**
|
|
372
|
+
* Per-project aggregates carried into workspace cells. Populated by
|
|
373
|
+
* the plugin from `ReporterRenderInput.reports`; empty for non-workspace
|
|
374
|
+
* shapes.
|
|
375
|
+
*/
|
|
376
|
+
readonly projects: ReadonlyArray<ProjectSummary>;
|
|
377
|
+
/**
|
|
378
|
+
* Trend direction for cells that surface a `Trend: …` line. `null`
|
|
379
|
+
* for scoped runs and any run where trend history is unavailable.
|
|
380
|
+
*/
|
|
381
|
+
readonly trend: TrendSummary | null;
|
|
382
|
+
/**
|
|
383
|
+
* Files below the aspirational `coverageTargets` tier. Workspace and
|
|
384
|
+
* project cells surface a truncated listing of these; single-file and
|
|
385
|
+
* single-test cells ignore them.
|
|
386
|
+
*/
|
|
387
|
+
readonly belowTarget: ReadonlyArray<FileCoverageReport>;
|
|
388
|
+
/**
|
|
389
|
+
* Configured run command (e.g. `pnpm test`). Cell footers reference
|
|
390
|
+
* this so copy-pasted commands stay accurate. `null` when no command
|
|
391
|
+
* was configured.
|
|
392
|
+
*/
|
|
393
|
+
readonly runCommand: string | null;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Render-time options threaded into each cell from the resolved
|
|
397
|
+
* `ReporterKit`. These are concerns the cell needs to format its
|
|
398
|
+
* output but that do not belong on the state-derived
|
|
399
|
+
* {@link DispatchInputs} struct.
|
|
400
|
+
*
|
|
401
|
+
* The plugin builds this once per run from the kit and passes it into
|
|
402
|
+
* `dispatch(inputs, opts)`. Cells destructure only what they consume.
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
interface CellOptions {
|
|
406
|
+
/**
|
|
407
|
+
* Resolved value of the `NO_COLOR` env var. Cells gate ANSI escape
|
|
408
|
+
* sequences and OSC-8 hyperlinks on this.
|
|
409
|
+
*/
|
|
410
|
+
readonly noColor: boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Pre-bound OSC-8 hyperlink helper. The plugin has already decided
|
|
413
|
+
* whether OSC-8 should be enabled (`target=stdout`, `!noColor`) so
|
|
414
|
+
* cells can call this directly without re-consulting the environment.
|
|
415
|
+
*/
|
|
416
|
+
readonly osc8: (url: string, label: string) => string;
|
|
417
|
+
} //#endregion
|
|
418
|
+
//#region src/schemas/Common.d.ts
|
|
419
|
+
/**
|
|
420
|
+
* Possible states for an individual test case.
|
|
421
|
+
* @public
|
|
422
|
+
*/
|
|
423
|
+
/**
|
|
424
|
+
* Classification of a test's failure history across runs.
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
declare const TestClassification: Schema.Literal<["stable", "new-failure", "persistent", "flaky", "recovered"]>;
|
|
428
|
+
/** @public */
|
|
429
|
+
type TestClassification = typeof TestClassification.Type;
|
|
430
|
+
/**
|
|
431
|
+
* Console output verbosity mode for AgentReporter.
|
|
432
|
+
* @public
|
|
433
|
+
*/
|
|
434
|
+
/**
|
|
435
|
+
* Union of every legal console-output value across the three executor slots.
|
|
436
|
+
* Useful for type-narrowing in renderers that take the resolved value.
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
declare const ConsoleMode: Schema.Union<[Schema.Literal<["passthrough", "silent", "stream", "agent"]>, Schema.Literal<["passthrough", "silent", "agent"]>, Schema.Literal<["passthrough", "silent", "ci-annotations"]>]>;
|
|
440
|
+
/** @public */
|
|
441
|
+
type ConsoleMode = typeof ConsoleMode.Type;
|
|
442
|
+
/**
|
|
443
|
+
* Supported package managers for run command generation.
|
|
444
|
+
* @public
|
|
445
|
+
*/
|
|
446
|
+
/**
|
|
447
|
+
* Runtime environment where tests are being executed.
|
|
448
|
+
* @public
|
|
449
|
+
*/
|
|
450
|
+
declare const Environment: Schema.Literal<["agent-shell", "terminal", "ci-github", "ci-generic"]>;
|
|
451
|
+
/** @public */
|
|
452
|
+
type Environment = typeof Environment.Type;
|
|
453
|
+
/**
|
|
454
|
+
* Who or what is executing the test run.
|
|
455
|
+
* @public
|
|
456
|
+
*/
|
|
457
|
+
declare const Executor: Schema.Literal<["human", "agent", "ci"]>;
|
|
458
|
+
/** @public */
|
|
459
|
+
type Executor = typeof Executor.Type;
|
|
460
|
+
/**
|
|
461
|
+
* Output format for the reporter pipeline.
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
declare const OutputFormat: Schema.Literal<["terminal", "markdown", "json", "vitest-bypass", "silent", "ci-annotations"]>;
|
|
465
|
+
/** @public */
|
|
466
|
+
type OutputFormat = typeof OutputFormat.Type;
|
|
467
|
+
/**
|
|
468
|
+
* Level of detail in reporter output.
|
|
469
|
+
* @public
|
|
470
|
+
*/
|
|
471
|
+
declare const DetailLevel: Schema.Literal<["minimal", "neutral", "standard", "verbose"]>;
|
|
472
|
+
/** @public */
|
|
473
|
+
type DetailLevel = typeof DetailLevel.Type;
|
|
474
|
+
/**
|
|
475
|
+
* A single test or module error with optional stack trace, diff, and
|
|
476
|
+
* structured assertion values.
|
|
477
|
+
*
|
|
478
|
+
* `expected` / `received` are pre-stringified, one-line representations
|
|
479
|
+
* of the assertion's expected and received JS values. They are populated
|
|
480
|
+
* only when the underlying test runner error carries structured `.expected`
|
|
481
|
+
* / `.actual` properties (assertion errors). The raw JS values stay in
|
|
482
|
+
* Vitest's internal error object; only the string representation crosses
|
|
483
|
+
* the schema boundary.
|
|
484
|
+
* @public
|
|
485
|
+
*/
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/formatters/types.d.ts
|
|
488
|
+
/** @public */
|
|
489
|
+
interface RenderedOutput {
|
|
490
|
+
readonly target: "stdout" | "file" | "github-summary";
|
|
491
|
+
readonly content: string;
|
|
492
|
+
readonly contentType: string;
|
|
493
|
+
}
|
|
494
|
+
/** @public */
|
|
495
|
+
/**
|
|
496
|
+
* The reducer projects this union into `RenderState`. Renderers
|
|
497
|
+
* never read the raw event stream — they read the projected state.
|
|
498
|
+
*
|
|
499
|
+
* @remarks
|
|
500
|
+
* Adding a variant here is one change in one place; the reducer's
|
|
501
|
+
* exhaustive `Match.exhaustive` will surface any renderer that hasn't
|
|
502
|
+
* been updated to consume the new state shape.
|
|
503
|
+
* @public
|
|
504
|
+
*/
|
|
505
|
+
declare const RunEvent: Schema.Union<[Schema.TaggedStruct<"RunStarted", {
|
|
506
|
+
runId: typeof Schema.String;
|
|
507
|
+
startedAt: typeof Schema.String;
|
|
508
|
+
configHash: typeof Schema.String;
|
|
509
|
+
}>, Schema.TaggedStruct<"ModuleQueued", {
|
|
510
|
+
modulePath: typeof Schema.String;
|
|
511
|
+
projectName: Schema.optional<typeof Schema.String>;
|
|
512
|
+
}>, Schema.TaggedStruct<"ModuleStarted", {
|
|
513
|
+
modulePath: typeof Schema.String;
|
|
514
|
+
startedAt: typeof Schema.String;
|
|
515
|
+
projectName: Schema.optional<typeof Schema.String>;
|
|
516
|
+
}>, Schema.TaggedStruct<"TestStarted", {
|
|
517
|
+
modulePath: typeof Schema.String;
|
|
518
|
+
testName: typeof Schema.String;
|
|
519
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
520
|
+
}>, Schema.TaggedStruct<"TestFinished", {
|
|
521
|
+
modulePath: typeof Schema.String;
|
|
522
|
+
testName: typeof Schema.String;
|
|
523
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
524
|
+
status: Schema.Literal<["passed", "failed", "skipped", "pending"]>;
|
|
525
|
+
durationMs: typeof Schema.Number;
|
|
526
|
+
error: Schema.optional<Schema.Struct<{
|
|
527
|
+
message: typeof Schema.String;
|
|
528
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
529
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
530
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
531
|
+
received: Schema.optional<typeof Schema.String>;
|
|
532
|
+
}>>;
|
|
533
|
+
timedOut: Schema.optional<typeof Schema.Boolean>;
|
|
534
|
+
}>, Schema.TaggedStruct<"ModuleFinished", {
|
|
535
|
+
modulePath: typeof Schema.String;
|
|
536
|
+
passCount: typeof Schema.Number;
|
|
537
|
+
failCount: typeof Schema.Number;
|
|
538
|
+
skipCount: typeof Schema.Number;
|
|
539
|
+
durationMs: typeof Schema.Number;
|
|
540
|
+
projectName: Schema.optional<typeof Schema.String>;
|
|
541
|
+
timeoutCount: Schema.optional<typeof Schema.Number>;
|
|
542
|
+
tagCounts: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Number>>;
|
|
543
|
+
}>, Schema.TaggedStruct<"ModuleCollected", {
|
|
544
|
+
modulePath: typeof Schema.String;
|
|
545
|
+
testCount: typeof Schema.Number;
|
|
546
|
+
suiteCount: typeof Schema.Number;
|
|
547
|
+
}>, Schema.TaggedStruct<"SuiteStarted", {
|
|
548
|
+
modulePath: typeof Schema.String;
|
|
549
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
550
|
+
suiteName: typeof Schema.String;
|
|
551
|
+
}>, Schema.TaggedStruct<"SuiteFinished", {
|
|
552
|
+
modulePath: typeof Schema.String;
|
|
553
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
554
|
+
suiteName: typeof Schema.String;
|
|
555
|
+
passCount: typeof Schema.Number;
|
|
556
|
+
failCount: typeof Schema.Number;
|
|
557
|
+
skipCount: typeof Schema.Number;
|
|
558
|
+
}>, Schema.TaggedStruct<"HookStarted", {
|
|
559
|
+
modulePath: typeof Schema.String;
|
|
560
|
+
hookType: Schema.Literal<["beforeAll", "afterAll", "beforeEach", "afterEach"]>;
|
|
561
|
+
scopeName: typeof Schema.String;
|
|
562
|
+
}>, Schema.TaggedStruct<"HookFinished", {
|
|
563
|
+
modulePath: typeof Schema.String;
|
|
564
|
+
hookType: Schema.Literal<["beforeAll", "afterAll", "beforeEach", "afterEach"]>;
|
|
565
|
+
scopeName: typeof Schema.String;
|
|
566
|
+
durationMs: typeof Schema.Number;
|
|
567
|
+
status: Schema.Literal<["passed", "failed"]>;
|
|
568
|
+
error: Schema.optional<Schema.Struct<{
|
|
569
|
+
message: typeof Schema.String;
|
|
570
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
571
|
+
diff: Schema.optional<typeof Schema.String>;
|
|
572
|
+
expected: Schema.optional<typeof Schema.String>;
|
|
573
|
+
received: Schema.optional<typeof Schema.String>;
|
|
574
|
+
}>>;
|
|
575
|
+
}>, Schema.TaggedStruct<"ConsoleLog", {
|
|
576
|
+
modulePath: Schema.optional<typeof Schema.String>;
|
|
577
|
+
testName: Schema.optional<typeof Schema.String>;
|
|
578
|
+
level: Schema.Literal<["stdout", "stderr"]>;
|
|
579
|
+
content: typeof Schema.String;
|
|
580
|
+
time: typeof Schema.Number;
|
|
581
|
+
}>, Schema.TaggedStruct<"RunTimedOut", {
|
|
582
|
+
message: typeof Schema.String;
|
|
583
|
+
}>, Schema.TaggedStruct<"TestAnnotated", {
|
|
584
|
+
modulePath: typeof Schema.String;
|
|
585
|
+
testName: typeof Schema.String;
|
|
586
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
587
|
+
annotation: typeof Schema.String;
|
|
588
|
+
}>, Schema.TaggedStruct<"TestArtifactRecorded", {
|
|
589
|
+
modulePath: typeof Schema.String;
|
|
590
|
+
testName: typeof Schema.String;
|
|
591
|
+
suitePath: Schema.Array$<typeof Schema.String>;
|
|
592
|
+
artifact: typeof Schema.String;
|
|
593
|
+
}>, Schema.TaggedStruct<"WatcherReady", {}>, Schema.TaggedStruct<"WatcherRerun", {
|
|
594
|
+
triggerFiles: Schema.Array$<typeof Schema.String>;
|
|
595
|
+
reason: Schema.optional<typeof Schema.String>;
|
|
596
|
+
}>, Schema.TaggedStruct<"TrendComputed", {
|
|
597
|
+
direction: Schema.Literal<["improving", "regressing", "stable"]>;
|
|
598
|
+
runCount: typeof Schema.Number;
|
|
599
|
+
}>, Schema.TaggedStruct<"CoverageReady", {
|
|
600
|
+
metrics: Schema.Struct<{
|
|
601
|
+
statements: typeof Schema.Number;
|
|
602
|
+
branches: typeof Schema.Number;
|
|
603
|
+
functions: typeof Schema.Number;
|
|
604
|
+
lines: typeof Schema.Number;
|
|
605
|
+
}>;
|
|
606
|
+
thresholds: Schema.Struct<{
|
|
607
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
608
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
609
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
610
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
611
|
+
}>;
|
|
612
|
+
gaps: Schema.Array$<Schema.Struct<{
|
|
613
|
+
file: typeof Schema.String;
|
|
614
|
+
missing: Schema.Struct<{
|
|
615
|
+
statements: typeof Schema.Number;
|
|
616
|
+
branches: typeof Schema.Number;
|
|
617
|
+
functions: typeof Schema.Number;
|
|
618
|
+
lines: typeof Schema.Number;
|
|
619
|
+
}>;
|
|
620
|
+
uncoveredLines: Schema.optional<typeof Schema.String>;
|
|
621
|
+
}>>;
|
|
622
|
+
}>, Schema.TaggedStruct<"ThresholdViolation", {
|
|
623
|
+
metric: Schema.Literal<["lines", "branches", "functions", "statements"]>;
|
|
624
|
+
expected: typeof Schema.Number;
|
|
625
|
+
actual: typeof Schema.Number;
|
|
626
|
+
}>, Schema.TaggedStruct<"FailureClassified", {
|
|
627
|
+
modulePath: typeof Schema.String;
|
|
628
|
+
testName: typeof Schema.String;
|
|
629
|
+
classification: Schema.Literal<["stable", "new-failure", "persistent", "flaky", "recovered"]>;
|
|
630
|
+
}>, Schema.TaggedStruct<"SuggestedAction", {
|
|
631
|
+
severity: Schema.Literal<["info", "warn", "blocker"]>;
|
|
632
|
+
title: typeof Schema.String;
|
|
633
|
+
detail: typeof Schema.String;
|
|
634
|
+
targetTool: Schema.optional<typeof Schema.String>;
|
|
635
|
+
}>, Schema.TaggedStruct<"RunFinished", {
|
|
636
|
+
runId: typeof Schema.String;
|
|
637
|
+
finishedAt: typeof Schema.String;
|
|
638
|
+
passCount: typeof Schema.Number;
|
|
639
|
+
failCount: typeof Schema.Number;
|
|
640
|
+
skipCount: typeof Schema.Number;
|
|
641
|
+
durationMs: typeof Schema.Number;
|
|
642
|
+
timeoutCount: Schema.optional<typeof Schema.Number>;
|
|
643
|
+
}>]>;
|
|
644
|
+
/** @public */
|
|
645
|
+
type RunEvent = typeof RunEvent.Type;
|
|
646
|
+
/**
|
|
647
|
+
* Convenience: discriminator-keyed map of the individual variants.
|
|
648
|
+
*
|
|
649
|
+
* Useful for callers that want to construct an event by tag without
|
|
650
|
+
* pulling the whole union shape into scope.
|
|
651
|
+
* @public
|
|
652
|
+
*/
|
|
653
|
+
/**
|
|
654
|
+
* Fully resolved thresholds ready for evaluation.
|
|
655
|
+
* @public
|
|
656
|
+
*/
|
|
657
|
+
declare const ResolvedThresholds: Schema.Struct<{
|
|
658
|
+
global: Schema.Struct<{
|
|
659
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
660
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
661
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
662
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
663
|
+
}>;
|
|
664
|
+
perFile: Schema.optionalWith<typeof Schema.Boolean, {
|
|
665
|
+
default: () => false;
|
|
666
|
+
}>;
|
|
667
|
+
patterns: Schema.optionalWith<Schema.Array$<Schema.Tuple2<typeof Schema.String, Schema.Struct<{
|
|
668
|
+
lines: Schema.optional<typeof Schema.Number>;
|
|
669
|
+
functions: Schema.optional<typeof Schema.Number>;
|
|
670
|
+
branches: Schema.optional<typeof Schema.Number>;
|
|
671
|
+
statements: Schema.optional<typeof Schema.Number>;
|
|
672
|
+
}>>>, {
|
|
673
|
+
default: () => never[];
|
|
674
|
+
}>;
|
|
675
|
+
}>;
|
|
676
|
+
/** @public */
|
|
677
|
+
type ResolvedThresholds = typeof ResolvedThresholds.Type; //#endregion
|
|
678
|
+
//#region src/schemas/Transport.d.ts
|
|
679
|
+
/**
|
|
680
|
+
* Transport binding for the persistence layer.
|
|
681
|
+
*
|
|
682
|
+
* 2.x ships only `{ kind: "local" }`. Modeled as a single-member
|
|
683
|
+
* discriminated union so the 3.0 cloud-backend swap (D1, Turso, etc.)
|
|
684
|
+
* lands as a pure addition of new union members — no schema-shape
|
|
685
|
+
* diff and no breaking API change at the call site.
|
|
686
|
+
* @public
|
|
687
|
+
*/
|
|
688
|
+
declare const Transport: Schema.Struct<{
|
|
689
|
+
kind: Schema.Literal<["local"]>;
|
|
690
|
+
}>;
|
|
691
|
+
/** @public */
|
|
692
|
+
type Transport = typeof Transport.Type; //#endregion
|
|
693
|
+
//#region src/contracts/reporter.d.ts
|
|
694
|
+
/**
|
|
695
|
+
* Config the plugin computes from its own options + Vitest's resolved config,
|
|
696
|
+
* then hands to the reporter factory inside {@link ReporterKit}.
|
|
697
|
+
*
|
|
698
|
+
* `dbPath` is optional at the type level so renderers that don't care about
|
|
699
|
+
* the persistence layer (e.g. a stdout-only renderer) can ignore it. The
|
|
700
|
+
* plugin always populates it in practice — the option exists for clarity
|
|
701
|
+
* and to leave room for future "no-persistence" experiments.
|
|
702
|
+
*
|
|
703
|
+
* `format` and `detail` are pre-resolved by the plugin (via
|
|
704
|
+
* `FormatSelector` / `DetailResolver`) but reporters that want to override
|
|
705
|
+
* can ignore them. `noColor` is the resolved value of the `NO_COLOR` env
|
|
706
|
+
* var; reporters use it to gate ANSI escapes and OSC-8 hyperlinks.
|
|
707
|
+
* @public
|
|
708
|
+
*/
|
|
709
|
+
interface ResolvedReporterConfig {
|
|
710
|
+
readonly dbPath?: string;
|
|
711
|
+
readonly projectFilter?: string;
|
|
712
|
+
/**
|
|
713
|
+
* The executor the plugin detected at run time (`human`, `agent`, `ci`).
|
|
714
|
+
* Renderers branch on this when their per-mode behavior depends on the
|
|
715
|
+
* observer (e.g. honoring `NO_COLOR` only when a human is watching).
|
|
716
|
+
*/
|
|
717
|
+
readonly executor: Executor;
|
|
718
|
+
/**
|
|
719
|
+
* The `ConsoleMode` value the plugin selected for the active
|
|
720
|
+
* executor — the result of looking up `console.{executor}` and falling
|
|
721
|
+
* back to the per-slot default. Renderers that need to know "what am I
|
|
722
|
+
* supposed to produce right now?" read this single field.
|
|
723
|
+
*/
|
|
724
|
+
readonly consoleMode: ConsoleMode;
|
|
725
|
+
readonly mcp: boolean;
|
|
726
|
+
readonly consoleOutput: "failures" | "full" | "silent";
|
|
727
|
+
readonly omitPassingTests: boolean;
|
|
728
|
+
readonly coverageConsoleLimit: number;
|
|
729
|
+
readonly includeBareZero: boolean;
|
|
730
|
+
readonly githubActions: boolean;
|
|
731
|
+
readonly githubSummary: boolean;
|
|
732
|
+
readonly githubSummaryFile?: string;
|
|
733
|
+
readonly coverageThresholds?: ResolvedThresholds;
|
|
734
|
+
readonly coverageTargets?: ResolvedThresholds;
|
|
735
|
+
/**
|
|
736
|
+
* Operating mode resolved from Vitest's native `coverage.enabled` config.
|
|
737
|
+
* - `"full"` — coverage is enabled; all analytics and persistence run.
|
|
738
|
+
* - `"ui-only"` — coverage is disabled (`coverage.enabled: false`); reporter
|
|
739
|
+
* renders output but the persistence pipeline is skipped (Phase 5).
|
|
740
|
+
*
|
|
741
|
+
* The plugin always resolves this field in `configureVitest`.
|
|
742
|
+
* @internal
|
|
743
|
+
*/
|
|
744
|
+
readonly coverageMode: "full" | "ui-only";
|
|
745
|
+
readonly format: OutputFormat;
|
|
746
|
+
readonly detail: DetailLevel;
|
|
747
|
+
readonly noColor: boolean;
|
|
748
|
+
readonly runCommand?: string;
|
|
749
|
+
/**
|
|
750
|
+
* Transport binding for the persistence layer. Custom reporters
|
|
751
|
+
* read this when they want to branch on backend kind (e.g. behave
|
|
752
|
+
* differently against a cloud DB). 2.x ships only `{ kind: "local" }`.
|
|
753
|
+
*/
|
|
754
|
+
readonly transport?: Transport;
|
|
755
|
+
/**
|
|
756
|
+
* Snapshot of Vitest's `test.passWithNoTests` policy captured from
|
|
757
|
+
* the resolved config at `configureVitest` time.
|
|
758
|
+
*
|
|
759
|
+
* Informational for consumer reporters that want to render the
|
|
760
|
+
* resolved policy alongside other run context. The MCP `run_tests`
|
|
761
|
+
* tool does not read this field — when its per-call
|
|
762
|
+
* `passWithNoTests` override is unset the tool forwards nothing to
|
|
763
|
+
* `createVitest`, and Vitest re-resolves from the project config on
|
|
764
|
+
* disk. The `no-match` discriminator is filter-driven and is not
|
|
765
|
+
* affected by this policy.
|
|
766
|
+
*
|
|
767
|
+
* Optional because the field is only present when populated by the
|
|
768
|
+
* plugin; consumers constructing `ResolvedReporterConfig` directly
|
|
769
|
+
* may omit it.
|
|
770
|
+
*/
|
|
771
|
+
readonly passWithNoTests?: boolean;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Plugin-provided primitives passed to the reporter factory at construction
|
|
775
|
+
* time. The `std*` prefix marks these as "the plugin gives you these — do
|
|
776
|
+
* not import equivalents yourself"; they are pre-resolved with full context
|
|
777
|
+
* (environment, executor, NO_COLOR, target=stdout) so the reporter doesn't
|
|
778
|
+
* have to re-derive that state.
|
|
779
|
+
*
|
|
780
|
+
* The shape is open to additions: future fields (e.g. `stdLogger`,
|
|
781
|
+
* `stdRuntime`) won't break existing reporters because the parameter is a
|
|
782
|
+
* named-field object. Reporters destructure only what they consume.
|
|
783
|
+
* @public
|
|
784
|
+
*/
|
|
785
|
+
interface ReporterKit {
|
|
786
|
+
readonly config: ResolvedReporterConfig;
|
|
787
|
+
readonly stdEnv: Environment;
|
|
788
|
+
/**
|
|
789
|
+
* Pre-bound OSC-8 hyperlink helper. The plugin has already decided
|
|
790
|
+
* whether OSC-8 should be enabled (target=stdout, !noColor) so the
|
|
791
|
+
* reporter can call this directly without consulting environment.
|
|
792
|
+
*/
|
|
793
|
+
readonly stdOsc8: (url: string, label: string) => string;
|
|
794
|
+
/**
|
|
795
|
+
* Live run-event channel. The plugin publishes one `RunEvent`
|
|
796
|
+
* per Vitest streaming callback (`onTestRunStart`, `onTestModuleStart`,
|
|
797
|
+
* `onTestCaseResult`, `onTestRunEnd`, …) onto this `PubSub` as the run
|
|
798
|
+
* progresses. A reporter that paints live — the default reporter's Ink
|
|
799
|
+
* mount in `consoleMode: "stream"` — subscribes here at construction time
|
|
800
|
+
* (the factory is invoked at run start, before the first event) and
|
|
801
|
+
* drives its renderer off the stream.
|
|
802
|
+
*
|
|
803
|
+
* Optional at the type level so a reporter constructed directly
|
|
804
|
+
* without the plugin (tests, one-shot replay) can omit it; a reporter
|
|
805
|
+
* that wants live events must guard for `undefined`. The plugin always
|
|
806
|
+
* populates it.
|
|
807
|
+
*/
|
|
808
|
+
readonly runEvents?: PubSub.PubSub<RunEvent>;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Per-run data handed to {@link VitestAgentReporter.render} after the plugin
|
|
812
|
+
* has finished persisting and classifying the run.
|
|
813
|
+
*
|
|
814
|
+
* `reports` is one entry per project (multi-project Vitest configs produce
|
|
815
|
+
* multiple). `classifications` is keyed by `TestReport.fullName` and is the
|
|
816
|
+
* stable / new-failure / persistent / flaky / recovered label assigned by
|
|
817
|
+
* `HistoryTracker`. `trendSummary` is present only on full (non-scoped) runs
|
|
818
|
+
* where coverage trends were computed.
|
|
819
|
+
* @public
|
|
820
|
+
*/
|
|
821
|
+
interface ReporterRenderInput {
|
|
822
|
+
readonly reports: ReadonlyArray<AgentReport>;
|
|
823
|
+
readonly classifications: ReadonlyMap<string, TestClassification>;
|
|
824
|
+
readonly trendSummary?: {
|
|
825
|
+
readonly direction: "improving" | "regressing" | "stable";
|
|
826
|
+
readonly runCount: number;
|
|
827
|
+
readonly firstMetric?: {
|
|
828
|
+
readonly name: string;
|
|
829
|
+
readonly from: number;
|
|
830
|
+
readonly to: number;
|
|
831
|
+
readonly target?: number;
|
|
832
|
+
};
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* The reporter contract. Implement this to plug a custom output strategy
|
|
837
|
+
* into `vitest-agent`.
|
|
838
|
+
*
|
|
839
|
+
* `render` is called once per test run after the plugin has persisted all
|
|
840
|
+
* data. It receives the assembled run plus a second, health-aware
|
|
841
|
+
* {@link ReporterKit}: the kit handed to the factory is resolved at run
|
|
842
|
+
* start (before failures are known), while the kit handed to `render` is
|
|
843
|
+
* resolved at run end and reflects post-run `detail`. A reporter that does
|
|
844
|
+
* construction-time work reads the factory kit; a reporter that renders
|
|
845
|
+
* reads the `render` kit. The reporter returns `RenderedOutput[]` — the
|
|
846
|
+
* plugin routes each entry to its declared `target` (`stdout`, `file`,
|
|
847
|
+
* `github-summary`), so the reporter does not need to know about file
|
|
848
|
+
* paths or write streams.
|
|
849
|
+
*
|
|
850
|
+
* A "no-op" reporter is one line: `() => ({ render: () => [] })`. Useful
|
|
851
|
+
* for users who only want persistence (the MCP/CLI tools see the data) and
|
|
852
|
+
* no console output at all.
|
|
853
|
+
* @public
|
|
854
|
+
*/
|
|
855
|
+
interface VitestAgentReporter {
|
|
856
|
+
readonly render: (input: ReporterRenderInput, kit: ReporterKit) => ReadonlyArray<RenderedOutput>;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Factory that the plugin's `reporter` option accepts. The plugin calls
|
|
860
|
+
* this once with the resolved kit; the factory returns either a single
|
|
861
|
+
* reporter or an array of reporters bound to that kit.
|
|
862
|
+
*
|
|
863
|
+
* Returning an array models Vitest's own multi-reporter pattern
|
|
864
|
+
* (`reporters: ['default', 'github-actions']`): each reporter handles
|
|
865
|
+
* its own concern (e.g. one for stdout markdown, one for SARIF, one
|
|
866
|
+
* for the GitHub Actions step summary) and the plugin concatenates
|
|
867
|
+
* their `RenderedOutput[]` before routing. Persistence still runs
|
|
868
|
+
* exactly once — the plugin owns the Vitest lifecycle and the
|
|
869
|
+
* reporters never see Vitest events directly.
|
|
870
|
+
*
|
|
871
|
+
* Defaulting to a factory (rather than passing a class or pre-made
|
|
872
|
+
* instance) gives implementations a place to do construction-time work
|
|
873
|
+
* (e.g. opening a file handle, capturing config) while still letting
|
|
874
|
+
* the plugin own the kit assembly.
|
|
875
|
+
* @public
|
|
876
|
+
*/
|
|
877
|
+
type VitestAgentReporterFactory = (kit: ReporterKit) => VitestAgentReporter | ReadonlyArray<VitestAgentReporter>; //#endregion
|
|
878
|
+
//#region src/errors/DiscoveryError.d.ts
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/defaultReporter.d.ts
|
|
881
|
+
/**
|
|
882
|
+
* Build a `DispatchInputs` from a {@link ReporterRenderInput} and
|
|
883
|
+
* the reduced `RenderState`.
|
|
884
|
+
*
|
|
885
|
+
* Exported so a custom reporter built on the same dispatcher can reuse
|
|
886
|
+
* this assembly step without rebuilding it from scratch.
|
|
887
|
+
*
|
|
888
|
+
* @public
|
|
889
|
+
*/
|
|
890
|
+
declare const buildDispatchInputs: (state: RenderState, input: ReporterRenderInput, overrides?: {
|
|
891
|
+
readonly shape?: RunShape;
|
|
892
|
+
readonly outcome?: RunOutcome;
|
|
893
|
+
readonly runCommand?: string | null;
|
|
894
|
+
}) => DispatchInputs;
|
|
895
|
+
/**
|
|
896
|
+
* Build `CellOptions` from a {@link ReporterKit}. Picks the kit's
|
|
897
|
+
* resolved `noColor` value and the pre-bound OSC-8 hyperlink helper.
|
|
898
|
+
*
|
|
899
|
+
* @public
|
|
900
|
+
*/
|
|
901
|
+
declare const resolveCellOptions: (kit: ReporterKit) => CellOptions;
|
|
902
|
+
/**
|
|
903
|
+
* Convenience helper for one-shot consumers (e.g. a CLI command
|
|
904
|
+
* replaying a stored run). Synthesizes a minimal `ReporterRenderInput`
|
|
905
|
+
* from a single `AgentReport`, classifies the shape and outcome, and
|
|
906
|
+
* returns the dispatched agent-string for the matching cell. Equivalent
|
|
907
|
+
* to the pre-2.0 `renderRun(events, "agent")` shortcut.
|
|
908
|
+
*
|
|
909
|
+
* @public
|
|
910
|
+
*/
|
|
911
|
+
declare const renderAgentStringForReport: (report: AgentReport) => string;
|
|
912
|
+
/**
|
|
913
|
+
* Same as {@link renderAgentStringForReport} but returns the Ink-half
|
|
914
|
+
* rendered to a string via Ink's `renderToString`. ANSI escape
|
|
915
|
+
* sequences are preserved so a terminal renders the colors live.
|
|
916
|
+
* Returns the agent-string fallback when the matched cell has no Ink
|
|
917
|
+
* half.
|
|
918
|
+
*
|
|
919
|
+
* @public
|
|
920
|
+
*/
|
|
921
|
+
declare const renderHumanStringForReport: (report: AgentReport, options?: {
|
|
922
|
+
readonly width?: number;
|
|
923
|
+
}) => Promise<string>;
|
|
924
|
+
/**
|
|
925
|
+
* The default reporter factory.
|
|
926
|
+
*
|
|
927
|
+
* The plugin uses this as its built-in when no user `reporter` option
|
|
928
|
+
* is supplied, and a custom-reporter author reads it as the canonical
|
|
929
|
+
* worked example of the `VitestAgentReporterFactory` contract.
|
|
930
|
+
*
|
|
931
|
+
* The factory is invoked once at run start with the run-start kit. In
|
|
932
|
+
* `consoleMode: "stream"` it subscribes a live Ink mount to the kit's
|
|
933
|
+
* run-event channel and owns that mount's lifecycle end to end.
|
|
934
|
+
*
|
|
935
|
+
* The `render` call (invoked once at run end with the health-aware kit)
|
|
936
|
+
* assembles the reduced state, classifies the shape and outcome, and
|
|
937
|
+
* dispatches to the matching cell. Output is one stdout entry carrying
|
|
938
|
+
* the cell's string. When `kit.config.githubActions` is true a GFM
|
|
939
|
+
* step-summary payload is appended for routing to GITHUB_STEP_SUMMARY.
|
|
940
|
+
* In `stream` mode `render` emits nothing — the live mount painted the run.
|
|
941
|
+
*
|
|
942
|
+
* @public
|
|
943
|
+
*/
|
|
944
|
+
declare const DefaultVitestAgentReporter: VitestAgentReporterFactory;
|
|
945
|
+
//#endregion
|
|
946
|
+
//#region src/LiveInkRenderer.d.ts
|
|
947
|
+
/**
|
|
948
|
+
* Options for `createLiveInk`.
|
|
949
|
+
*
|
|
950
|
+
* @public
|
|
951
|
+
*/
|
|
952
|
+
interface CreateLiveInkOptions {
|
|
953
|
+
/**
|
|
954
|
+
* Override the stream Ink writes to. Defaults to `process.stdout`.
|
|
955
|
+
* Tests pass a captured Writable here to assert on rendered frames.
|
|
956
|
+
*/
|
|
957
|
+
readonly stream?: NodeJS.WriteStream;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Imperative handle returned by `createLiveInk`. Drives a live
|
|
961
|
+
* Ink mount across the lifetime of a test run, including watch-mode reruns.
|
|
962
|
+
*
|
|
963
|
+
* @public
|
|
964
|
+
*/
|
|
965
|
+
interface LiveInkRenderer {
|
|
966
|
+
/**
|
|
967
|
+
* Process a `RunEvent`. Mounts the Ink tree and starts the
|
|
968
|
+
* animation clock on `RunStarted`, rerenders on every event that
|
|
969
|
+
* mutates state, and unmounts on the terminal event so Ink commits
|
|
970
|
+
* the final frame to scrollback.
|
|
971
|
+
*/
|
|
972
|
+
readonly event: (event: RunEvent) => void;
|
|
973
|
+
/**
|
|
974
|
+
* Force an immediate unmount and stop the animation clock. Safe to
|
|
975
|
+
* call multiple times. Useful in tests or when the host needs to
|
|
976
|
+
* tear down out of band (e.g. a cancellation signal).
|
|
977
|
+
*/
|
|
978
|
+
readonly unmount: () => void;
|
|
979
|
+
/**
|
|
980
|
+
* Latest reduced state. Exposed for hosts that want to assert on the
|
|
981
|
+
* accumulated value at any point during the run.
|
|
982
|
+
*/
|
|
983
|
+
readonly snapshot: () => RenderState;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Create a {@link LiveInkRenderer} that drives a live Ink mount for
|
|
987
|
+
* `consoleMode: "stream"`. Call `event(e)` for each `RunEvent` published
|
|
988
|
+
* by the plugin; the renderer mounts on `RunStarted`, rerenders on each
|
|
989
|
+
* subsequent event, and commits the final frame on `RunFinished` /
|
|
990
|
+
* `RunTimedOut`.
|
|
991
|
+
*
|
|
992
|
+
* @public
|
|
993
|
+
*/
|
|
994
|
+
declare const createLiveInk: (options?: CreateLiveInkOptions) => LiveInkRenderer;
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/index.d.ts
|
|
997
|
+
/**
|
|
998
|
+
* The version of this package, inlined at build time from
|
|
999
|
+
* package.json#version via rslib-builder's __PACKAGE_VERSION__ substitution.
|
|
1000
|
+
* The reporter is consumed through the plugin so it does not run its own
|
|
1001
|
+
* init-time drift check, but the constant is exported so the plugin can
|
|
1002
|
+
* compare against it. See the root CLAUDE.md "Cross-package version drift"
|
|
1003
|
+
* section.
|
|
1004
|
+
*
|
|
1005
|
+
* @public
|
|
1006
|
+
*/
|
|
1007
|
+
declare const CURRENT_REPORTER_VERSION: string;
|
|
1008
|
+
//#endregion
|
|
1009
|
+
export { type AgentReport, CURRENT_REPORTER_VERSION, type CellOptions, type ConsoleMode, type CreateLiveInkOptions, DefaultVitestAgentReporter, type DetailLevel, type DispatchInputs, type Environment, type Executor, type FileCoverageReport, type LiveInkRenderer, type OutputFormat, type ProjectSummary, type RenderState, type RenderedOutput, type ReporterKit, type ReporterRenderInput, type ResolvedReporterConfig, type ResolvedThresholds, type RunEvent, type RunOutcome, type RunShape, type TestClassification, type Transport, type TrendSummary, type VitestAgentReporter, type VitestAgentReporterFactory, createLiveInk as _createLiveInk, buildDispatchInputs, renderAgentStringForReport, renderHumanStringForReport, resolveCellOptions };
|
|
1010
|
+
//# sourceMappingURL=index.d.ts.map
|