@swedevtools/livedoc-vitest 0.2.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/README.md +95 -0
- package/dist/RuleContext-BZhuy-zS.d.cts +206 -0
- package/dist/RuleContext-BZhuy-zS.d.ts +206 -0
- package/dist/globals.cjs +2 -0
- package/dist/globals.d.cts +104 -0
- package/dist/globals.d.ts +104 -0
- package/dist/globals.js +1 -0
- package/dist/index-Blmp569T.d.cts +687 -0
- package/dist/index-CysiWbtk.d.ts +687 -0
- package/dist/index.cjs +10024 -0
- package/dist/index.d.cts +291 -0
- package/dist/index.d.ts +291 -0
- package/dist/index.js +9933 -0
- package/dist/playwright/index.cjs +103 -0
- package/dist/playwright/index.d.cts +129 -0
- package/dist/playwright/index.d.ts +129 -0
- package/dist/playwright/index.js +99 -0
- package/dist/reporter/index.cjs +8676 -0
- package/dist/reporter/index.d.cts +7 -0
- package/dist/reporter/index.d.ts +7 -0
- package/dist/reporter/index.js +8635 -0
- package/dist/setup.cjs +14 -0
- package/dist/setup.d.cts +2 -0
- package/dist/setup.d.ts +2 -0
- package/dist/setup.js +12 -0
- package/package.json +135 -0
- package/tools/livedoc-setup.mjs +164 -0
- package/tools/skills/SKILL.md +244 -0
- package/tools/skills/VALIDATION.md +29 -0
- package/tools/skills/examples/routing.md +60 -0
- package/tools/skills/resources/bdd-features.md +231 -0
- package/tools/skills/resources/playwright.md +148 -0
- package/tools/skills/resources/reporter-config.md +163 -0
- package/tools/skills/resources/specifications.md +159 -0
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
import { Reporter } from 'vitest/reporters';
|
|
2
|
+
import { File, TaskResultPack } from '@vitest/runner';
|
|
3
|
+
import { Vitest } from 'vitest/node';
|
|
4
|
+
import { D as DataTableRow, a as StepContext, F as FeatureContext, B as BackgroundContext, S as ScenarioContext, R as RuleContext, b as SpecificationContext } from './RuleContext-BZhuy-zS.cjs';
|
|
5
|
+
import { Attachment, TestRunV1 } from '@swedevtools/livedoc-schema';
|
|
6
|
+
import { RunnerTestFile } from 'vitest';
|
|
7
|
+
|
|
8
|
+
declare enum RuleViolations {
|
|
9
|
+
/**
|
|
10
|
+
* Is triggered when a more generic error occurs
|
|
11
|
+
*/
|
|
12
|
+
error = 0,
|
|
13
|
+
/**
|
|
14
|
+
* Is triggered when a scenario, scenarioOutline or background is used without a feature
|
|
15
|
+
*/
|
|
16
|
+
missingFeature = 1,
|
|
17
|
+
/**
|
|
18
|
+
* Is triggered if a given, when or then is not a child of a scenario, scenarioOutline or background
|
|
19
|
+
*/
|
|
20
|
+
givenWhenThenMustBeWithinScenario = 2,
|
|
21
|
+
/**
|
|
22
|
+
* Is triggered when more than 1 given, when or then is used within a single scenario, scenarioOutline or background
|
|
23
|
+
*/
|
|
24
|
+
singleGivenWhenThen = 3,
|
|
25
|
+
/**
|
|
26
|
+
* Is triggered if no given is part of the test
|
|
27
|
+
*/
|
|
28
|
+
mustIncludeGiven = 4,
|
|
29
|
+
/**
|
|
30
|
+
* Is triggered if no when is part of the test
|
|
31
|
+
*/
|
|
32
|
+
mustIncludeWhen = 5,
|
|
33
|
+
/**
|
|
34
|
+
* Is triggered if no then is part of the test
|
|
35
|
+
*/
|
|
36
|
+
mustIncludeThen = 6,
|
|
37
|
+
/**
|
|
38
|
+
* Is triggered when an and or but doesn't also include a given, when or then
|
|
39
|
+
*/
|
|
40
|
+
andButMustHaveGivenWhenThen = 7,
|
|
41
|
+
/**
|
|
42
|
+
* Is triggered when the Gherkin language is mixed with other BDD language
|
|
43
|
+
*/
|
|
44
|
+
mustNotMixLanguages = 8,
|
|
45
|
+
/**
|
|
46
|
+
* Is triggered if a background uses when or then
|
|
47
|
+
*/
|
|
48
|
+
backgroundMustOnlyIncludeGiven = 9,
|
|
49
|
+
/**
|
|
50
|
+
* Using the before hook has the same affect as the given step definition but with the ability to convey meaning.
|
|
51
|
+
* It is therefore encouraged to use a given over the before hook.
|
|
52
|
+
*/
|
|
53
|
+
enforceUsingGivenOverBefore = 10,
|
|
54
|
+
/**
|
|
55
|
+
* Ensures that a title is specified for keywords that require it
|
|
56
|
+
*/
|
|
57
|
+
enforceTitle = 11
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare class LiveDocRuleViolation extends Error {
|
|
61
|
+
rule: RuleViolations;
|
|
62
|
+
title: string;
|
|
63
|
+
private static errorCount;
|
|
64
|
+
private _errorId;
|
|
65
|
+
constructor(rule: RuleViolations, message: string, title: string);
|
|
66
|
+
get errorId(): number;
|
|
67
|
+
toJSON(): object;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare enum SpecStatus {
|
|
71
|
+
unknown = "unknown",
|
|
72
|
+
pending = "pending",
|
|
73
|
+
pass = "pass",
|
|
74
|
+
fail = "fail"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class Exception {
|
|
78
|
+
actual: string;
|
|
79
|
+
expected: string;
|
|
80
|
+
message: string;
|
|
81
|
+
stackTrace: string;
|
|
82
|
+
toJSON(): object;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare class Statistics<T = any> {
|
|
86
|
+
parent?: T;
|
|
87
|
+
totalCount: number;
|
|
88
|
+
passCount: number;
|
|
89
|
+
failedCount: number;
|
|
90
|
+
pendingCount: number;
|
|
91
|
+
totalRuleViolations: number;
|
|
92
|
+
duration: number;
|
|
93
|
+
passPercent: number;
|
|
94
|
+
failedPercent: number;
|
|
95
|
+
pendingPercent: number;
|
|
96
|
+
constructor(parent?: T);
|
|
97
|
+
updateStats(status: SpecStatus, duration: number): void;
|
|
98
|
+
toJSON(): object;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Base class for all test suites (Feature, Scenario, Background, etc.)
|
|
103
|
+
*/
|
|
104
|
+
declare class SuiteBase<T> {
|
|
105
|
+
type: string;
|
|
106
|
+
id: string;
|
|
107
|
+
sequence: number;
|
|
108
|
+
statistics: Statistics<T>;
|
|
109
|
+
title: string;
|
|
110
|
+
tags: string[];
|
|
111
|
+
path: string;
|
|
112
|
+
constructor();
|
|
113
|
+
generateId(item: any): void;
|
|
114
|
+
protected validateIdUniqueness(id: string, children: any[]): void;
|
|
115
|
+
/**
|
|
116
|
+
* Simple hash function to replace hash-sum dependency
|
|
117
|
+
*/
|
|
118
|
+
private simpleHash;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare class LiveDocSuite extends SuiteBase<LiveDocSuite> {
|
|
122
|
+
rawDescription: string;
|
|
123
|
+
ruleViolations: LiveDocRuleViolation[];
|
|
124
|
+
displayTitle: string;
|
|
125
|
+
description: string;
|
|
126
|
+
constructor();
|
|
127
|
+
addViolation(rule: RuleViolations, message: string, title: string): void;
|
|
128
|
+
addViolationInstance(violation: LiveDocRuleViolation): void;
|
|
129
|
+
registerRuleViolation(): void;
|
|
130
|
+
toJSON(): object;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Represents a Vitest describe/suite (non-Gherkin tests)
|
|
135
|
+
* Replaces MochaSuite for Vitest compatibility
|
|
136
|
+
*/
|
|
137
|
+
declare class VitestSuite extends SuiteBase<VitestSuite> {
|
|
138
|
+
parent?: VitestSuite;
|
|
139
|
+
children: VitestSuite[];
|
|
140
|
+
tests: LiveDocTest<VitestSuite>[];
|
|
141
|
+
filename: string;
|
|
142
|
+
constructor(parent: VitestSuite | null, title: string, type: string);
|
|
143
|
+
toJSON(): object;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class LiveDocTest<P extends LiveDocSuite | VitestSuite> {
|
|
147
|
+
title: string;
|
|
148
|
+
parent: P;
|
|
149
|
+
id: string;
|
|
150
|
+
sequence: number;
|
|
151
|
+
duration: number;
|
|
152
|
+
status: SpecStatus;
|
|
153
|
+
code: string;
|
|
154
|
+
exception: Exception;
|
|
155
|
+
constructor(parent: P, title: string);
|
|
156
|
+
setStatus(status: SpecStatus, duration: number): void;
|
|
157
|
+
toJSON(): object;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare class StepDefinition extends LiveDocTest<Scenario> {
|
|
161
|
+
private _displayTitle;
|
|
162
|
+
private _docString;
|
|
163
|
+
private _passedParam?;
|
|
164
|
+
rawTitle: string;
|
|
165
|
+
type: string;
|
|
166
|
+
description: string;
|
|
167
|
+
docStringRaw: string;
|
|
168
|
+
dataTable: DataTableRow[];
|
|
169
|
+
values: any[];
|
|
170
|
+
valuesRaw: string[];
|
|
171
|
+
params: Record<string, any>;
|
|
172
|
+
paramsRaw: Record<string, string>;
|
|
173
|
+
ruleViolations: LiveDocRuleViolation[];
|
|
174
|
+
attachments: Attachment[];
|
|
175
|
+
associatedScenarioId: number;
|
|
176
|
+
get passedParam(): object | undefined;
|
|
177
|
+
set passedParam(value: object | (() => object) | undefined);
|
|
178
|
+
get displayTitle(): string;
|
|
179
|
+
set displayTitle(value: string);
|
|
180
|
+
get docString(): string;
|
|
181
|
+
set docString(value: string);
|
|
182
|
+
getStepContext(): StepContext;
|
|
183
|
+
addViolation(rule: RuleViolations, message: string, title: string): void;
|
|
184
|
+
toJSON(): object;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
declare class Feature extends LiveDocSuite {
|
|
188
|
+
filename: string;
|
|
189
|
+
background?: Background;
|
|
190
|
+
scenarios: Scenario[];
|
|
191
|
+
executionTime: number;
|
|
192
|
+
constructor();
|
|
193
|
+
addScenario(scenario: Scenario): void;
|
|
194
|
+
getFeatureContext(): FeatureContext;
|
|
195
|
+
getBackgroundContext(): BackgroundContext | undefined;
|
|
196
|
+
toJSON(): object;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare class Scenario extends LiveDocSuite {
|
|
200
|
+
parent: Feature;
|
|
201
|
+
givens: StepDefinition[];
|
|
202
|
+
whens: StepDefinition[];
|
|
203
|
+
steps: StepDefinition[];
|
|
204
|
+
associatedFeatureId: number;
|
|
205
|
+
executionTime: number;
|
|
206
|
+
private hasGiven;
|
|
207
|
+
private hasWhen;
|
|
208
|
+
private hasThen;
|
|
209
|
+
private processingStepType;
|
|
210
|
+
constructor(parent: Feature);
|
|
211
|
+
addStep(step: StepDefinition): void;
|
|
212
|
+
private addGivenWhenThenViolation;
|
|
213
|
+
getScenarioContext(): ScenarioContext;
|
|
214
|
+
toJSON(): object;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
declare class Background extends Scenario {
|
|
218
|
+
constructor(parent: Feature);
|
|
219
|
+
addStep(step: StepDefinition): void;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare class Table {
|
|
223
|
+
name: string;
|
|
224
|
+
description: string;
|
|
225
|
+
dataTable: DataTableRow[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Extended context for scenario outlines including example data
|
|
230
|
+
*/
|
|
231
|
+
interface ScenarioOutlineContext {
|
|
232
|
+
title: string;
|
|
233
|
+
description: string;
|
|
234
|
+
example: DataTableRow;
|
|
235
|
+
exampleRaw: DataTableRow;
|
|
236
|
+
given?: any;
|
|
237
|
+
and: any[];
|
|
238
|
+
tags: string[];
|
|
239
|
+
steps: any[];
|
|
240
|
+
}
|
|
241
|
+
declare class ScenarioExample extends Scenario {
|
|
242
|
+
example: DataTableRow;
|
|
243
|
+
exampleRaw: DataTableRow;
|
|
244
|
+
scenarioOutline: ScenarioOutline;
|
|
245
|
+
constructor(parent: Feature, scenarioOutline: ScenarioOutline);
|
|
246
|
+
addStep(step: StepDefinition): void;
|
|
247
|
+
getScenarioContext(): ScenarioOutlineContext;
|
|
248
|
+
private bind;
|
|
249
|
+
private sanitizeName;
|
|
250
|
+
toJSON(): object;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The computed scenario from a ScenarioOutline definition
|
|
255
|
+
* Differs from a standard scenario as it includes examples
|
|
256
|
+
*/
|
|
257
|
+
declare class ScenarioOutline extends Scenario {
|
|
258
|
+
tables: Table[];
|
|
259
|
+
examples: ScenarioExample[];
|
|
260
|
+
/**
|
|
261
|
+
* Blueprint steps parsed from the Scenario Outline title block.
|
|
262
|
+
* These contain the original DocStrings and Data Tables from Gherkin.
|
|
263
|
+
*/
|
|
264
|
+
blueprintSteps: StepDefinition[];
|
|
265
|
+
constructor(parent: Feature);
|
|
266
|
+
toJSON(): object;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Rule is a simple specification assertion.
|
|
271
|
+
* Unlike Scenario, it doesn't have step functions (given/when/then).
|
|
272
|
+
* The test body contains assertions directly.
|
|
273
|
+
*/
|
|
274
|
+
declare class Rule extends LiveDocSuite {
|
|
275
|
+
parent: Specification;
|
|
276
|
+
executionTime: number;
|
|
277
|
+
status: SpecStatus;
|
|
278
|
+
error?: Error;
|
|
279
|
+
code: string;
|
|
280
|
+
exception: Exception;
|
|
281
|
+
valuesRaw: string[];
|
|
282
|
+
values: any[];
|
|
283
|
+
paramsRaw: Record<string, string>;
|
|
284
|
+
params: Record<string, any>;
|
|
285
|
+
constructor(parent: Specification);
|
|
286
|
+
setStatus(status: SpecStatus, duration: number): void;
|
|
287
|
+
getRuleContext(): RuleContext;
|
|
288
|
+
toJSON(): object;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Specification is the top-level container for the Specification pattern.
|
|
293
|
+
* It contains Rules (simple) and RuleOutlines (data-driven).
|
|
294
|
+
* Unlike Feature/Scenario, specifications don't use step functions.
|
|
295
|
+
*/
|
|
296
|
+
declare class Specification extends LiveDocSuite {
|
|
297
|
+
filename: string;
|
|
298
|
+
rules: Rule[];
|
|
299
|
+
executionTime: number;
|
|
300
|
+
constructor();
|
|
301
|
+
addRule(rule: Rule): void;
|
|
302
|
+
getSpecificationContext(): SpecificationContext;
|
|
303
|
+
toJSON(): object;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Aggregates execution results for all features and suites
|
|
308
|
+
*/
|
|
309
|
+
declare class ExecutionResults {
|
|
310
|
+
features: Feature[];
|
|
311
|
+
specifications: Specification[];
|
|
312
|
+
suites: VitestSuite[];
|
|
313
|
+
/** Stores any exception that was thrown during execution and should be re-thrown to the caller */
|
|
314
|
+
thrownException?: {
|
|
315
|
+
type: string;
|
|
316
|
+
message: string;
|
|
317
|
+
data?: any;
|
|
318
|
+
};
|
|
319
|
+
addFeature(feature: Feature): void;
|
|
320
|
+
addSpecification(specification: Specification): void;
|
|
321
|
+
addSuite(suite: VitestSuite): void;
|
|
322
|
+
toJSON(): object;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* LiveDoc reporter for Vitest
|
|
327
|
+
* Provides Gherkin-style output for BDD tests
|
|
328
|
+
*/
|
|
329
|
+
declare class LiveDocVitestReporter implements Reporter {
|
|
330
|
+
onInit(_ctx: any): void;
|
|
331
|
+
onCollected(_files?: File[]): void;
|
|
332
|
+
onTaskUpdate(_packs: TaskResultPack[]): void;
|
|
333
|
+
onFinished(files?: File[], errors?: unknown[]): void;
|
|
334
|
+
private processFile;
|
|
335
|
+
private writeLine;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Vitest Reporter that provides enhanced BDD output using LiveDocSpec
|
|
340
|
+
* Follows the pattern from JUnitReporter and SummaryReporter
|
|
341
|
+
*/
|
|
342
|
+
declare class LiveDocSpecReporter implements Reporter {
|
|
343
|
+
private liveDocSpec;
|
|
344
|
+
private options;
|
|
345
|
+
private exportConfig;
|
|
346
|
+
private streamEnabled;
|
|
347
|
+
private taskById;
|
|
348
|
+
private streamedStates;
|
|
349
|
+
constructor(options?: any);
|
|
350
|
+
onInit(ctx: Vitest): Promise<void>;
|
|
351
|
+
onCollected(files?: File[]): void;
|
|
352
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
353
|
+
private normalizeTaskResultPack;
|
|
354
|
+
private computeIndent;
|
|
355
|
+
onTestRunEnd(testModules: readonly any[]): Promise<void>;
|
|
356
|
+
private exportTestRunJson;
|
|
357
|
+
private buildExecutionResults;
|
|
358
|
+
private buildFeatureFromSuite;
|
|
359
|
+
private buildScenarioOutlineFromNestedStructure;
|
|
360
|
+
private buildBackgroundFromSuite;
|
|
361
|
+
private buildScenarioFromSuite;
|
|
362
|
+
private buildScenarioExampleFromSuite;
|
|
363
|
+
private getLiveDocMetaFromTask;
|
|
364
|
+
private findFirstLiveDocStepMetaInSuite;
|
|
365
|
+
private buildScenarioOutlineTablesFromMeta;
|
|
366
|
+
private parseTitleBlock;
|
|
367
|
+
private sanitizeName;
|
|
368
|
+
private buildStepFromTest;
|
|
369
|
+
private sanitizeExampleKeys;
|
|
370
|
+
private extractStepTitle;
|
|
371
|
+
private parseStepContent;
|
|
372
|
+
private parseDataTableFromLines;
|
|
373
|
+
private setLiveDocOptions;
|
|
374
|
+
private createPathFromFile;
|
|
375
|
+
private buildSpecificationFromSuite;
|
|
376
|
+
private buildRuleFromTest;
|
|
377
|
+
private buildRuleOutlineFromSuite;
|
|
378
|
+
private buildRuleExampleFromTest;
|
|
379
|
+
private mapTaskStateToSpecStatus;
|
|
380
|
+
private buildVitestSuiteFromTask;
|
|
381
|
+
private buildVitestTestFromTask;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Color theme for LiveDoc reporters
|
|
386
|
+
*/
|
|
387
|
+
interface ColorTheme {
|
|
388
|
+
tags: (text: string) => string;
|
|
389
|
+
comments: (text: string) => string;
|
|
390
|
+
keyword: (text: string) => string;
|
|
391
|
+
featureTitle: (text: string) => string;
|
|
392
|
+
featureDescription: (text: string) => string;
|
|
393
|
+
backgroundTitle: (text: string) => string;
|
|
394
|
+
backgroundDescription: (text: string) => string;
|
|
395
|
+
scenarioTitle: (text: string) => string;
|
|
396
|
+
scenarioDescription: (text: string) => string;
|
|
397
|
+
stepTitle: (text: string) => string;
|
|
398
|
+
stepDescription: (text: string) => string;
|
|
399
|
+
stepKeyword: (text: string) => string;
|
|
400
|
+
statusPending: (text: string) => string & {
|
|
401
|
+
inverse: (text: string) => string;
|
|
402
|
+
};
|
|
403
|
+
statusUnknown: (text: string) => string;
|
|
404
|
+
statusPass: (text: string) => string & {
|
|
405
|
+
inverse: (text: string) => string;
|
|
406
|
+
};
|
|
407
|
+
statusFail: (text: string) => string & {
|
|
408
|
+
inverse: (text: string) => string;
|
|
409
|
+
};
|
|
410
|
+
dataTable: (text: string) => string & {
|
|
411
|
+
bold: (text: string) => string;
|
|
412
|
+
};
|
|
413
|
+
dataTableHeader: (text: string) => string;
|
|
414
|
+
docString: (text: string) => string;
|
|
415
|
+
valuePlaceholders: (text: string) => string;
|
|
416
|
+
summaryHeader: (text: string) => string;
|
|
417
|
+
}
|
|
418
|
+
declare const DefaultColorTheme: ColorTheme;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Interface for post-execution reporters
|
|
422
|
+
* These run after all tests complete to generate additional reports
|
|
423
|
+
*/
|
|
424
|
+
interface IPostReporter {
|
|
425
|
+
/**
|
|
426
|
+
* Execute the reporter with the test results
|
|
427
|
+
* @param results The execution results from all tests
|
|
428
|
+
* @param options Reporter-specific options
|
|
429
|
+
*/
|
|
430
|
+
execute(results: ExecutionResults, options?: any): void | Promise<void>;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
declare class ReporterOptions {
|
|
434
|
+
colors: ColorTheme;
|
|
435
|
+
options: Object;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
declare class JsonReporter implements IPostReporter {
|
|
439
|
+
execute(results: ExecutionResults, options: any): Promise<void>;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* A silent reporter that produces no output but captures errors.
|
|
444
|
+
* Used for dynamic test execution where we don't want any console output.
|
|
445
|
+
* Implements the Vitest Reporter interface.
|
|
446
|
+
*/
|
|
447
|
+
declare class SilentReporter implements Reporter {
|
|
448
|
+
collectedErrors: Error[];
|
|
449
|
+
collectedFiles: RunnerTestFile[];
|
|
450
|
+
onInit(): void;
|
|
451
|
+
onPathsCollected(): void;
|
|
452
|
+
onCollected(files?: RunnerTestFile[]): void;
|
|
453
|
+
onFinished(files?: RunnerTestFile[], errors?: unknown[]): void;
|
|
454
|
+
onTaskUpdate(): void;
|
|
455
|
+
onTestRemoved(): void;
|
|
456
|
+
onWatcherStart(): void;
|
|
457
|
+
onWatcherRerun(): void;
|
|
458
|
+
onServerRestart(): void;
|
|
459
|
+
onUserConsoleLog(): void;
|
|
460
|
+
onProcessTimeout(): void;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
interface LiveDocViewerOptions {
|
|
464
|
+
server?: string;
|
|
465
|
+
project?: string;
|
|
466
|
+
environment?: string;
|
|
467
|
+
timeout?: number;
|
|
468
|
+
silent?: boolean;
|
|
469
|
+
}
|
|
470
|
+
declare class LiveDocViewerReporter implements IPostReporter {
|
|
471
|
+
private options;
|
|
472
|
+
constructor(options?: LiveDocViewerOptions);
|
|
473
|
+
execute(results: ExecutionResults, rawOptions?: any): Promise<void>;
|
|
474
|
+
/**
|
|
475
|
+
* Builds a complete TestRunV1 object from ExecutionResults without making any HTTP calls.
|
|
476
|
+
* Used for direct JSON file export on CI where no server is running.
|
|
477
|
+
*/
|
|
478
|
+
buildTestRun(results: ExecutionResults, rawOptions?: any): TestRunV1;
|
|
479
|
+
startRunSession(rawOptions?: any): Promise<string | null>;
|
|
480
|
+
postResultsToRun(runId: string, results: ExecutionResults): Promise<void>;
|
|
481
|
+
completeRunFromResults(runId: string, results: ExecutionResults): Promise<void>;
|
|
482
|
+
private applyRawOptions;
|
|
483
|
+
private startRun;
|
|
484
|
+
private upsertTestCase;
|
|
485
|
+
private buildPathContext;
|
|
486
|
+
private findCommonRootPath;
|
|
487
|
+
private buildFileInfo;
|
|
488
|
+
private buildFeatureTestCase;
|
|
489
|
+
private buildSpecificationTestCase;
|
|
490
|
+
private buildSuiteTestCase;
|
|
491
|
+
private buildScenario;
|
|
492
|
+
private buildScenarioLike;
|
|
493
|
+
private buildScenarioOutline;
|
|
494
|
+
private buildRule;
|
|
495
|
+
private buildRuleOutline;
|
|
496
|
+
private buildStepTest;
|
|
497
|
+
private mapStepRichDataToDataTables;
|
|
498
|
+
private mapStepDataTable;
|
|
499
|
+
private mapStepValues;
|
|
500
|
+
private mapKeyword;
|
|
501
|
+
private stepExecution;
|
|
502
|
+
private scenarioExecutionFromSteps;
|
|
503
|
+
private aggregateStatus;
|
|
504
|
+
private computeStatisticsFromTests;
|
|
505
|
+
private mapMetaTablesToDataTables;
|
|
506
|
+
private buildScenarioOutlineExampleResults;
|
|
507
|
+
private buildRuleOutlineExampleResults;
|
|
508
|
+
private computeOutlineStatistics;
|
|
509
|
+
private computeRuleOutlineStatistics;
|
|
510
|
+
private toTypedValue;
|
|
511
|
+
private completeRun;
|
|
512
|
+
private mapStatus;
|
|
513
|
+
private calculateScenarioStatus;
|
|
514
|
+
private calculateOutlineStatus;
|
|
515
|
+
private calculateOverallStatus;
|
|
516
|
+
private calculateSummary;
|
|
517
|
+
private mapRuleViolations;
|
|
518
|
+
private post;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Base class for all LiveDoc reporters providing formatting utilities
|
|
523
|
+
* and abstract methods for feature/scenario/step hooks
|
|
524
|
+
*/
|
|
525
|
+
declare abstract class LiveDocReporter {
|
|
526
|
+
protected colorTheme: ColorTheme;
|
|
527
|
+
protected useColors: boolean;
|
|
528
|
+
constructor(colorTheme: ColorTheme, useColors?: boolean);
|
|
529
|
+
/**
|
|
530
|
+
* Returns a string highlighting the differences between the actual
|
|
531
|
+
* and expected strings.
|
|
532
|
+
*/
|
|
533
|
+
protected createUnifiedDiff(actual: any, expected: any): string;
|
|
534
|
+
/**
|
|
535
|
+
* Returns the content indented by the number of spaces specified
|
|
536
|
+
*/
|
|
537
|
+
protected applyBlockIndent(content: string, indent: number): string;
|
|
538
|
+
/**
|
|
539
|
+
* Will highlight matches based on the supplied regEx with the supplied color
|
|
540
|
+
*/
|
|
541
|
+
protected highlight(content: string, regex: RegExp, color: any): string;
|
|
542
|
+
/**
|
|
543
|
+
* Will return the string substituting placeholders defined with <..> with
|
|
544
|
+
* the value from the example
|
|
545
|
+
*/
|
|
546
|
+
protected bind(content: string, model: any, color: any): string;
|
|
547
|
+
/**
|
|
548
|
+
* Will return the string substituting placeholders defined with {{..}} with
|
|
549
|
+
* the value from the passed parameter
|
|
550
|
+
*/
|
|
551
|
+
protected secondaryBind(content: string, model: any, color: any): string;
|
|
552
|
+
/**
|
|
553
|
+
* Will return the string substituting named values defined with <name:value> with
|
|
554
|
+
* the value part
|
|
555
|
+
*/
|
|
556
|
+
protected namedBind(content: string, color: any): string;
|
|
557
|
+
private applyBinding;
|
|
558
|
+
protected escapeRegExp(text: string): string;
|
|
559
|
+
protected sanitizeName(name: string): string;
|
|
560
|
+
/**
|
|
561
|
+
* Returns a formatted table of the dataTable data
|
|
562
|
+
*/
|
|
563
|
+
protected formatTable(dataTable: any[][], headerStyle: HeaderType, includeRowId?: boolean, runningTotal?: number): string;
|
|
564
|
+
/**
|
|
565
|
+
* Finds the common root path from an array of file paths
|
|
566
|
+
*/
|
|
567
|
+
static findRootPath(strs: string[]): string;
|
|
568
|
+
protected createPathFromFile(filename: string, rootPath: string): string;
|
|
569
|
+
/**
|
|
570
|
+
* Adds the text to the reporters output stream
|
|
571
|
+
*/
|
|
572
|
+
protected writeLine(text: string): void;
|
|
573
|
+
/**
|
|
574
|
+
* Adds the text to the reporters output stream without a line return
|
|
575
|
+
*/
|
|
576
|
+
protected write(text: string): void;
|
|
577
|
+
protected executionStart(): void;
|
|
578
|
+
protected executionEnd(_results: ExecutionResults): void;
|
|
579
|
+
protected featureStart(_feature: Feature): void;
|
|
580
|
+
protected featureEnd(_feature: Feature): void;
|
|
581
|
+
protected scenarioStart(_scenario: Scenario): void;
|
|
582
|
+
protected scenarioEnd(_scenario: Scenario): void;
|
|
583
|
+
protected scenarioOutlineStart(_scenario: ScenarioOutline): void;
|
|
584
|
+
protected scenarioOutlineEnd(_scenario: ScenarioOutline): void;
|
|
585
|
+
protected scenarioExampleStart(_example: ScenarioExample): void;
|
|
586
|
+
protected scenarioExampleEnd(_example: ScenarioExample): void;
|
|
587
|
+
protected backgroundStart(_background: Background): void;
|
|
588
|
+
protected backgroundEnd(_background: Background): void;
|
|
589
|
+
protected stepStart(_step: StepDefinition): void;
|
|
590
|
+
protected stepEnd(_step: StepDefinition): void;
|
|
591
|
+
protected stepExampleStart(_step: StepDefinition): void;
|
|
592
|
+
protected stepExampleEnd(_step: StepDefinition): void;
|
|
593
|
+
protected suiteStart(_suite: VitestSuite): void;
|
|
594
|
+
protected suiteEnd(_suite: VitestSuite): void;
|
|
595
|
+
protected testStart(_test: LiveDocTest<VitestSuite>): void;
|
|
596
|
+
protected testEnd(_test: LiveDocTest<VitestSuite>): void;
|
|
597
|
+
}
|
|
598
|
+
declare enum HeaderType {
|
|
599
|
+
none = 0,
|
|
600
|
+
Top = 1,
|
|
601
|
+
Left = 2
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
declare class LiveDocReporterOptions {
|
|
605
|
+
auto: boolean;
|
|
606
|
+
spec: boolean;
|
|
607
|
+
summary: boolean;
|
|
608
|
+
list: boolean;
|
|
609
|
+
headers: boolean;
|
|
610
|
+
silent: boolean;
|
|
611
|
+
output: string;
|
|
612
|
+
/**
|
|
613
|
+
* Used to remove text from the header during summary output in Spec Reporter
|
|
614
|
+
* This option is mostly used when testing across a mono-repo and want to remove
|
|
615
|
+
* mono-repo specifics
|
|
616
|
+
*/
|
|
617
|
+
removeHeaderText: string;
|
|
618
|
+
setDefaults(): void;
|
|
619
|
+
enableSilent(): void;
|
|
620
|
+
}
|
|
621
|
+
declare class LiveDocSpec extends LiveDocReporter {
|
|
622
|
+
protected options: LiveDocReporterOptions;
|
|
623
|
+
private suiteIndent;
|
|
624
|
+
private static errorCount;
|
|
625
|
+
protected setOptions(options: LiveDocReporterOptions): void;
|
|
626
|
+
executionStart(): void;
|
|
627
|
+
executionEnd(results: ExecutionResults, options?: any): Promise<void>;
|
|
628
|
+
private outputSuiteDetails;
|
|
629
|
+
private outputSpecificationDetails;
|
|
630
|
+
private getStatusIndicator;
|
|
631
|
+
featureStart(feature: Feature): void;
|
|
632
|
+
featureEnd(feature: Feature): void;
|
|
633
|
+
scenarioStart(scenario: Scenario): void;
|
|
634
|
+
scenarioEnd(scenario: Scenario): void;
|
|
635
|
+
scenarioOutlineStart(scenario: ScenarioOutline): void;
|
|
636
|
+
scenarioOutlineEnd(_scenario: ScenarioOutline): void;
|
|
637
|
+
scenarioExampleStart(example: ScenarioExample): void;
|
|
638
|
+
scenarioExampleEnd(_example: ScenarioExample): void;
|
|
639
|
+
stepExampleStart(_step: StepDefinition): void;
|
|
640
|
+
stepExampleEnd(step: StepDefinition): void;
|
|
641
|
+
backgroundStart(background: Background): void;
|
|
642
|
+
backgroundEnd(_background: Background): void;
|
|
643
|
+
stepStart(_step: StepDefinition): void;
|
|
644
|
+
stepEnd(step: StepDefinition): void;
|
|
645
|
+
suiteStart(suite: VitestSuite): void;
|
|
646
|
+
suiteEnd(_suite: VitestSuite): void;
|
|
647
|
+
testStart(_test: LiveDocTest<VitestSuite>): void;
|
|
648
|
+
testEnd(test: LiveDocTest<VitestSuite>): void;
|
|
649
|
+
protected writeRuleViolations(violations: LiveDocRuleViolation[]): void;
|
|
650
|
+
protected writeLine(text: string): void;
|
|
651
|
+
private outputFeature;
|
|
652
|
+
private outputScenarioOutline;
|
|
653
|
+
private outputScenario;
|
|
654
|
+
/**
|
|
655
|
+
* Derives a scenario-level status from its step-level statistics.
|
|
656
|
+
* Any failed step → fail; all steps pass → pass; otherwise pending.
|
|
657
|
+
*/
|
|
658
|
+
private deriveScenarioStatus;
|
|
659
|
+
/**
|
|
660
|
+
* Computes scenario-level test counts for a feature.
|
|
661
|
+
* Each plain Scenario = 1 test; each ScenarioOutline example = 1 test.
|
|
662
|
+
*/
|
|
663
|
+
private computeFeatureTestCounts;
|
|
664
|
+
/**
|
|
665
|
+
* Computes scenario-level test counts for an individual scenario row.
|
|
666
|
+
* Plain Scenario: 1/0/0, 0/1/0, or 0/0/1. ScenarioOutline: counts its examples.
|
|
667
|
+
*/
|
|
668
|
+
private computeScenarioTestCounts;
|
|
669
|
+
private outputFeatureExecutionSummary;
|
|
670
|
+
private formatDuration;
|
|
671
|
+
private formatLine;
|
|
672
|
+
private outputSpecificationExecutionSummary;
|
|
673
|
+
private outputSuiteExecutionSummary;
|
|
674
|
+
private statusBar;
|
|
675
|
+
private outputExceptionReport;
|
|
676
|
+
private outputFeatureError;
|
|
677
|
+
private outputSpecificationError;
|
|
678
|
+
private outputSuiteError;
|
|
679
|
+
private outputStepError;
|
|
680
|
+
private outputStep;
|
|
681
|
+
private outputTest;
|
|
682
|
+
private formatKeywordTitle;
|
|
683
|
+
private formatDescription;
|
|
684
|
+
private formatTags;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export { Background as B, type ColorTheme as C, DefaultColorTheme as D, Exception as E, Feature as F, HeaderType as H, type IPostReporter as I, JsonReporter as J, LiveDocReporter as L, Rule as R, Specification as S, Table as T, VitestSuite as V, Scenario as a, ScenarioOutline as b, StepDefinition as c, ExecutionResults as d, LiveDocReporterOptions as e, LiveDocRuleViolation as f, LiveDocSpecReporter as g, LiveDocSpec as h, LiveDocSuite as i, LiveDocTest as j, type LiveDocViewerOptions as k, LiveDocViewerReporter as l, LiveDocVitestReporter as m, ReporterOptions as n, RuleViolations as o, ScenarioExample as p, type ScenarioOutlineContext as q, SilentReporter as r, SpecStatus as s, Statistics as t, SuiteBase as u };
|