@wdio/reporter 9.0.0-alpha.9 → 9.0.4

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.
@@ -0,0 +1,784 @@
1
+ const __importMetaUrl = require('url').pathToFileURL(__filename).href;
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ HookStats: () => HookStats,
35
+ RunnerStats: () => RunnerStats,
36
+ SuiteStats: () => SuiteStats,
37
+ TestStats: () => TestStats,
38
+ default: () => WDIOReporter
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+ var import_node_fs = __toESM(require("node:fs"), 1);
42
+ var import_node_events = require("node:events");
43
+
44
+ // src/supportsColor.ts
45
+ var import_node_process = __toESM(require("node:process"), 1);
46
+ var import_node_os = __toESM(require("node:os"), 1);
47
+ var import_node_tty = __toESM(require("node:tty"), 1);
48
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
49
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
50
+ const position = argv.indexOf(prefix + flag);
51
+ const terminatorPosition = argv.indexOf("--");
52
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
53
+ }
54
+ var { env } = import_node_process.default;
55
+ var flagForceColor;
56
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
57
+ flagForceColor = 0;
58
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
59
+ flagForceColor = 1;
60
+ }
61
+ function envForceColor() {
62
+ if ("FORCE_COLOR" in env) {
63
+ if (env.FORCE_COLOR === "true") {
64
+ return 1;
65
+ }
66
+ if (env.FORCE_COLOR === "false") {
67
+ return 0;
68
+ }
69
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
70
+ }
71
+ }
72
+ function translateLevel(level) {
73
+ if (level === 0) {
74
+ return false;
75
+ }
76
+ return {
77
+ level,
78
+ hasBasic: true,
79
+ has256: level >= 2,
80
+ has16m: level >= 3
81
+ };
82
+ }
83
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
84
+ const noFlagForceColor = envForceColor();
85
+ if (noFlagForceColor !== void 0) {
86
+ flagForceColor = noFlagForceColor;
87
+ }
88
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
89
+ if (forceColor === 0) {
90
+ return 0;
91
+ }
92
+ if (sniffFlags) {
93
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
94
+ return 3;
95
+ }
96
+ if (hasFlag("color=256")) {
97
+ return 2;
98
+ }
99
+ }
100
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
101
+ return 1;
102
+ }
103
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
104
+ return 0;
105
+ }
106
+ const min = forceColor || 0;
107
+ if (env.TERM === "dumb") {
108
+ return min;
109
+ }
110
+ if (import_node_process.default.platform === "win32") {
111
+ const osRelease = import_node_os.default.release().split(".");
112
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
113
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
114
+ }
115
+ return 1;
116
+ }
117
+ if ("CI" in env) {
118
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
119
+ return 3;
120
+ }
121
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
122
+ return 1;
123
+ }
124
+ return min;
125
+ }
126
+ if ("TEAMCITY_VERSION" in env) {
127
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
128
+ }
129
+ if (env.COLORTERM === "truecolor") {
130
+ return 3;
131
+ }
132
+ if (env.TERM === "xterm-kitty") {
133
+ return 3;
134
+ }
135
+ if ("TERM_PROGRAM" in env) {
136
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
137
+ switch (env.TERM_PROGRAM) {
138
+ case "iTerm.app": {
139
+ return version >= 3 ? 3 : 2;
140
+ }
141
+ case "Apple_Terminal": {
142
+ return 2;
143
+ }
144
+ }
145
+ }
146
+ if (env.TERM && /-256(color)?$/i.test(env.TERM)) {
147
+ return 2;
148
+ }
149
+ if (env.TERM && /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
150
+ return 1;
151
+ }
152
+ if ("COLORTERM" in env) {
153
+ return 1;
154
+ }
155
+ return min;
156
+ }
157
+ function createSupportsColor(stream, options = {}) {
158
+ const level = _supportsColor(stream, {
159
+ streamIsTTY: stream && stream.isTTY,
160
+ ...options
161
+ });
162
+ return translateLevel(level);
163
+ }
164
+ var supportsColor = {
165
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
166
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
167
+ };
168
+ var supportsColor_default = supportsColor;
169
+
170
+ // src/constants.ts
171
+ var COLORS = {
172
+ pass: 90,
173
+ fail: 31,
174
+ "bright pass": 92,
175
+ "bright fail": 91,
176
+ "bright yellow": 93,
177
+ pending: 36,
178
+ suite: 0,
179
+ "error title": 0,
180
+ "error message": 31,
181
+ "error stack": 90,
182
+ checkmark: 32,
183
+ fast: 90,
184
+ medium: 33,
185
+ slow: 31,
186
+ green: 32,
187
+ light: 90,
188
+ "diff gutter": 90,
189
+ "diff added": 32,
190
+ "diff removed": 31,
191
+ "diff added inline": "30;42",
192
+ "diff removed inline": "30;41"
193
+ };
194
+
195
+ // src/utils.ts
196
+ var FIRST_FUNCTION_REGEX = /function (\w+)/;
197
+ function sanitizeString(str) {
198
+ if (!str) {
199
+ return "";
200
+ }
201
+ return String(str).replace(/^.*\/([^/]+)\/?$/, "$1").replace(/\./g, "_").replace(/\s/g, "").toLowerCase();
202
+ }
203
+ function sanitizeCaps(caps) {
204
+ if (!caps) {
205
+ return "";
206
+ }
207
+ let result;
208
+ result = caps["appium:deviceName"] || caps.deviceName ? [
209
+ sanitizeString(caps.platformName),
210
+ // @ts-expect-error outdated JSONWP capabilities
211
+ sanitizeString(caps["appium:deviceName"] || caps.deviceName),
212
+ sanitizeString(caps["appium:platformVersion"]),
213
+ sanitizeString(caps["appium:app"])
214
+ ] : [
215
+ sanitizeString(caps.browserName),
216
+ // @ts-expect-error outdated JSONWP capabilities
217
+ sanitizeString(caps.version || caps.browserVersion),
218
+ // @ts-expect-error outdated JSONWP capabilities
219
+ sanitizeString(caps.platform || caps.platformName),
220
+ sanitizeString(caps["appium:app"])
221
+ ];
222
+ result = result.filter((n) => n !== void 0 && n !== "");
223
+ return result.join(".");
224
+ }
225
+ function getErrorsFromEvent(e) {
226
+ if (e.errors) {
227
+ return e.errors;
228
+ }
229
+ if (e.error) {
230
+ return [e.error];
231
+ }
232
+ return [];
233
+ }
234
+ function pad(str, len) {
235
+ return Array(len - str.length + 1).join(" ") + str;
236
+ }
237
+ function color(type, content) {
238
+ if (!supportsColor_default.stdout) {
239
+ return String(content);
240
+ }
241
+ return `\x1B[${COLORS[type]}m${content}\x1B[0m`;
242
+ }
243
+ function colorLines(name, str) {
244
+ return str.split("\n").map((str2) => color(name, str2)).join("\n");
245
+ }
246
+ function transformCommandScript(script) {
247
+ if (!script) {
248
+ return script;
249
+ }
250
+ let name = void 0;
251
+ if (typeof script === "string") {
252
+ name = FIRST_FUNCTION_REGEX.exec(script);
253
+ FIRST_FUNCTION_REGEX.exec("");
254
+ } else if (typeof script === "function") {
255
+ name = script.name;
256
+ script = script.toString();
257
+ } else {
258
+ return `<${typeof script}>`;
259
+ }
260
+ if (typeof name === "string" && name) {
261
+ return `<script fn ${name}(...)> [${Buffer.byteLength(script, "utf-8")} bytes]`;
262
+ }
263
+ return `<script> [${Buffer.byteLength(script, "utf-8")} bytes]`;
264
+ }
265
+
266
+ // src/stats/runnable.ts
267
+ var RunnableStats = class {
268
+ constructor(type) {
269
+ this.type = type;
270
+ }
271
+ start = /* @__PURE__ */ new Date();
272
+ end;
273
+ _duration = 0;
274
+ complete() {
275
+ this.end = /* @__PURE__ */ new Date();
276
+ this._duration = this.end.getTime() - this.start.getTime();
277
+ }
278
+ get duration() {
279
+ if (this.end) {
280
+ return this._duration;
281
+ }
282
+ return (/* @__PURE__ */ new Date()).getTime() - this.start.getTime();
283
+ }
284
+ /**
285
+ * ToDo: we should always rely on uid
286
+ */
287
+ static getIdentifier(runner) {
288
+ return runner.uid || runner.title;
289
+ }
290
+ };
291
+
292
+ // src/stats/suite.ts
293
+ var SuiteStats = class extends RunnableStats {
294
+ uid;
295
+ cid;
296
+ file;
297
+ title;
298
+ fullTitle;
299
+ tags;
300
+ tests = [];
301
+ hooks = [];
302
+ suites = [];
303
+ parent;
304
+ /**
305
+ * an array of hooks and tests stored in order as they happen
306
+ */
307
+ hooksAndTests = [];
308
+ description;
309
+ rule;
310
+ constructor(suite) {
311
+ super(suite.type || "suite");
312
+ this.uid = RunnableStats.getIdentifier(suite);
313
+ this.cid = suite.cid;
314
+ this.file = suite.file;
315
+ this.title = suite.title;
316
+ this.fullTitle = suite.fullTitle;
317
+ this.tags = suite.tags;
318
+ this.parent = suite.parent;
319
+ this.description = suite.description;
320
+ this.rule = suite.rule;
321
+ }
322
+ };
323
+
324
+ // src/stats/hook.ts
325
+ var HookStats = class extends RunnableStats {
326
+ uid;
327
+ cid;
328
+ title;
329
+ parent;
330
+ // Mocha only
331
+ body;
332
+ errors;
333
+ error;
334
+ state;
335
+ currentTest;
336
+ constructor(runner) {
337
+ super("hook");
338
+ this.uid = RunnableStats.getIdentifier(runner);
339
+ this.cid = runner.cid;
340
+ this.title = runner.title;
341
+ this.parent = runner.parent;
342
+ this.currentTest = runner.currentTest;
343
+ this.body = runner.body;
344
+ }
345
+ complete(errors) {
346
+ this.errors = errors;
347
+ if (errors && errors.length) {
348
+ this.error = errors[0];
349
+ this.state = "failed";
350
+ }
351
+ super.complete();
352
+ }
353
+ };
354
+
355
+ // src/stats/test.ts
356
+ var import_node_util = require("node:util");
357
+ var import_diff = require("diff");
358
+ var import_object_inspect = __toESM(require("object-inspect"), 1);
359
+ var maxStringLength = 2048;
360
+ var TestStats = class extends RunnableStats {
361
+ uid;
362
+ cid;
363
+ title;
364
+ currentTest;
365
+ fullTitle;
366
+ output;
367
+ argument;
368
+ retries;
369
+ parent;
370
+ /**
371
+ * initial test state is pending
372
+ * the state can change to the following: passed, skipped, failed
373
+ */
374
+ state;
375
+ pendingReason;
376
+ errors;
377
+ error;
378
+ body;
379
+ constructor(test) {
380
+ super("test");
381
+ this.uid = RunnableStats.getIdentifier(test);
382
+ this.cid = test.cid;
383
+ this.title = test.title;
384
+ this.fullTitle = test.fullTitle;
385
+ this.output = [];
386
+ this.argument = test.argument;
387
+ this.retries = test.retries;
388
+ this.parent = test.parent;
389
+ this.body = test.body;
390
+ this.state = "pending";
391
+ }
392
+ pass() {
393
+ this.complete();
394
+ this.state = "passed";
395
+ }
396
+ skip(reason) {
397
+ this.pendingReason = reason;
398
+ this.state = "skipped";
399
+ }
400
+ fail(errors) {
401
+ this.complete();
402
+ this.state = "failed";
403
+ const formattedErrors = errors?.map((err) => (
404
+ /**
405
+ * only format if error object has either an "expected" or "actual" property set
406
+ */
407
+ (err.expected || err.actual) && !import_node_util.types.isProxy(err.actual) && /**
408
+ * and if they aren't already formated, e.g. in Jasmine
409
+ */
410
+ (err.message && !err.message.includes("Expected: ") && !err.message.includes("Received: ")) ? this._stringifyDiffObjs(err) : err
411
+ ));
412
+ this.errors = formattedErrors;
413
+ if (formattedErrors && formattedErrors.length) {
414
+ this.error = formattedErrors[0];
415
+ }
416
+ }
417
+ _stringifyDiffObjs(err) {
418
+ const inspectOpts = { maxStringLength };
419
+ const expected = (0, import_object_inspect.default)(err.expected, inspectOpts);
420
+ const actual = (0, import_object_inspect.default)(err.actual, inspectOpts);
421
+ let msg = (0, import_diff.diffWordsWithSpace)(actual, expected).map((str) => str.added ? colorLines("diff added inline", str.value) : str.removed ? colorLines("diff removed inline", str.value) : str.value).join("");
422
+ const lines = msg.split("\n");
423
+ if (lines.length > 4) {
424
+ const width = String(lines.length).length;
425
+ msg = lines.map(function(str, i) {
426
+ return pad(String(++i), width) + " | " + str;
427
+ }).join("\n");
428
+ }
429
+ msg = `
430
+ ${color("diff removed inline", "actual")} ${color("diff added inline", "expected")}
431
+
432
+ ${msg}
433
+ `;
434
+ msg = msg.replace(/^/gm, " ");
435
+ const newError = new Error(err.message + msg);
436
+ newError.stack = err.stack;
437
+ return newError;
438
+ }
439
+ };
440
+
441
+ // src/stats/runner.ts
442
+ var RunnerStats = class extends RunnableStats {
443
+ cid;
444
+ capabilities;
445
+ sanitizedCapabilities;
446
+ config;
447
+ specs;
448
+ sessionId;
449
+ isMultiremote;
450
+ instanceOptions;
451
+ retry;
452
+ failures;
453
+ retries;
454
+ constructor(runner) {
455
+ super("runner");
456
+ this.cid = runner.cid;
457
+ this.capabilities = runner.capabilities;
458
+ this.sanitizedCapabilities = sanitizeCaps(runner.capabilities);
459
+ this.config = runner.config;
460
+ this.specs = runner.specs;
461
+ this.sessionId = runner.sessionId;
462
+ this.isMultiremote = runner.isMultiremote;
463
+ this.instanceOptions = runner.instanceOptions;
464
+ this.retry = runner.retry;
465
+ }
466
+ };
467
+
468
+ // src/index.ts
469
+ var WDIOReporter = class extends import_node_events.EventEmitter {
470
+ constructor(options) {
471
+ super();
472
+ this.options = options;
473
+ if (this.options.outputDir) {
474
+ try {
475
+ import_node_fs.default.mkdirSync(this.options.outputDir, { recursive: true });
476
+ } catch (err) {
477
+ throw new Error(`Couldn't create output directory at "${this.options.outputDir}": ${err.stack}`);
478
+ }
479
+ }
480
+ this.outputStream = (this.options.stdout || !this.options.logFile) && this.options.writeStream ? this.options.writeStream : import_node_fs.default.createWriteStream(this.options.logFile);
481
+ let currentTest;
482
+ const rootSuite = new SuiteStats({
483
+ title: "(root)",
484
+ fullTitle: "(root)",
485
+ file: ""
486
+ });
487
+ this.currentSuites.push(rootSuite);
488
+ this.on("client:beforeCommand", this.onBeforeCommand.bind(this));
489
+ this.on("client:afterCommand", this.onAfterCommand.bind(this));
490
+ this.on("client:beforeAssertion", this.onBeforeAssertion.bind(this));
491
+ this.on("client:afterAssertion", this.onAfterAssertion.bind(this));
492
+ this.on(
493
+ "runner:start",
494
+ /* istanbul ignore next */
495
+ (runner) => {
496
+ rootSuite.cid = runner.cid;
497
+ this.specs.push(...runner.specs);
498
+ this.runnerStat = new RunnerStats(runner);
499
+ this.onRunnerStart(this.runnerStat);
500
+ }
501
+ );
502
+ this.on(
503
+ "suite:start",
504
+ /* istanbul ignore next */
505
+ (params) => {
506
+ if (!params.file) {
507
+ params.file = !params.parent ? this.specs.shift() || "unknown spec file" : this.currentSpec;
508
+ this.currentSpec = params.file;
509
+ }
510
+ const suite = new SuiteStats(params);
511
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
512
+ currentSuite.suites.push(suite);
513
+ this.currentSuites.push(suite);
514
+ this.suites[suite.uid] = suite;
515
+ this.onSuiteStart(suite);
516
+ }
517
+ );
518
+ this.on(
519
+ "hook:start",
520
+ /* istanbul ignore next */
521
+ (hook) => {
522
+ const hookStats = new HookStats(hook);
523
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
524
+ currentSuite.hooks.push(hookStats);
525
+ currentSuite.hooksAndTests.push(hookStats);
526
+ this.hooks[hook.uid] = hookStats;
527
+ this.onHookStart(hookStats);
528
+ }
529
+ );
530
+ this.on(
531
+ "hook:end",
532
+ /* istanbul ignore next */
533
+ (hook) => {
534
+ const hookStats = this.hooks[hook.uid];
535
+ hookStats.complete(getErrorsFromEvent(hook));
536
+ this.counts.hooks++;
537
+ this.onHookEnd(hookStats);
538
+ }
539
+ );
540
+ this.on(
541
+ "test:start",
542
+ /* istanbul ignore next */
543
+ (test) => {
544
+ test.retries = this.retries;
545
+ currentTest = new TestStats(test);
546
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
547
+ currentSuite.tests.push(currentTest);
548
+ currentSuite.hooksAndTests.push(currentTest);
549
+ this.tests[test.uid] = currentTest;
550
+ this.onTestStart(currentTest);
551
+ }
552
+ );
553
+ this.on(
554
+ "test:pass",
555
+ /* istanbul ignore next */
556
+ (test) => {
557
+ const testStat = this.tests[test.uid];
558
+ testStat.pass();
559
+ this.counts.passes++;
560
+ this.counts.tests++;
561
+ this.onTestPass(testStat);
562
+ }
563
+ );
564
+ this.on("test:skip", (test) => {
565
+ const testStat = this.tests[test.uid];
566
+ currentTest.skip(test.pendingReason);
567
+ this.counts.skipping++;
568
+ this.counts.tests++;
569
+ this.onTestSkip(testStat);
570
+ });
571
+ this.on(
572
+ "test:fail",
573
+ /* istanbul ignore next */
574
+ (test) => {
575
+ const testStat = this.tests[test.uid];
576
+ testStat.fail(getErrorsFromEvent(test));
577
+ this.counts.failures++;
578
+ this.counts.tests++;
579
+ this.onTestFail(testStat);
580
+ }
581
+ );
582
+ this.on("test:retry", (test) => {
583
+ const testStat = this.tests[test.uid];
584
+ testStat.fail(getErrorsFromEvent(test));
585
+ this.onTestRetry(testStat);
586
+ this.retries++;
587
+ });
588
+ this.on("test:pending", (test) => {
589
+ test.retries = this.retries;
590
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
591
+ currentTest = new TestStats(test);
592
+ if (test.uid in this.tests && this.tests[test.uid].state !== "pending") {
593
+ currentTest.uid = test.uid in this.tests ? "skipped-" + this.counts.skipping : currentTest.uid;
594
+ }
595
+ const suiteTests = currentSuite.tests;
596
+ if (!suiteTests.length || currentTest.uid !== suiteTests[suiteTests.length - 1].uid) {
597
+ currentSuite.tests.push(currentTest);
598
+ currentSuite.hooksAndTests.push(currentTest);
599
+ } else {
600
+ suiteTests[suiteTests.length - 1] = currentTest;
601
+ currentSuite.hooksAndTests[currentSuite.hooksAndTests.length - 1] = currentTest;
602
+ }
603
+ this.tests[currentTest.uid] = currentTest;
604
+ currentTest.skip(test.pendingReason);
605
+ this.counts.skipping++;
606
+ this.counts.tests++;
607
+ this.onTestSkip(currentTest);
608
+ });
609
+ this.on(
610
+ "test:end",
611
+ /* istanbul ignore next */
612
+ (test) => {
613
+ const testStat = this.tests[test.uid];
614
+ this.retries = 0;
615
+ this.onTestEnd(testStat);
616
+ }
617
+ );
618
+ this.on(
619
+ "suite:end",
620
+ /* istanbul ignore next */
621
+ (suite) => {
622
+ const suiteStat = this.suites[suite.uid];
623
+ suiteStat.complete();
624
+ this.currentSuites.pop();
625
+ this.onSuiteEnd(suiteStat);
626
+ }
627
+ );
628
+ this.on(
629
+ "runner:end",
630
+ /* istanbul ignore next */
631
+ (runner) => {
632
+ rootSuite.complete();
633
+ if (this.runnerStat) {
634
+ this.runnerStat.failures = runner.failures;
635
+ this.runnerStat.retries = runner.retries;
636
+ this.runnerStat.complete();
637
+ this.onRunnerEnd(this.runnerStat);
638
+ }
639
+ const logFile = this.options.logFile;
640
+ if (!this.isContentPresent && logFile && import_node_fs.default.existsSync(logFile)) {
641
+ import_node_fs.default.unlinkSync(logFile);
642
+ }
643
+ }
644
+ );
645
+ this.on(
646
+ "client:beforeCommand",
647
+ /* istanbul ignore next */
648
+ (payload) => {
649
+ if (!currentTest) {
650
+ return;
651
+ }
652
+ if (payload.body?.script) {
653
+ payload.body = {
654
+ ...payload.body,
655
+ script: transformCommandScript(payload.body.script)
656
+ };
657
+ }
658
+ currentTest.output.push(Object.assign(payload, { type: "command" }));
659
+ }
660
+ );
661
+ this.on(
662
+ "client:afterCommand",
663
+ /* istanbul ignore next */
664
+ (payload) => {
665
+ if (!currentTest) {
666
+ return;
667
+ }
668
+ if (payload.body?.script) {
669
+ payload.body = {
670
+ ...payload.body,
671
+ script: transformCommandScript(payload.body.script)
672
+ };
673
+ }
674
+ currentTest.output.push(Object.assign(payload, { type: "result" }));
675
+ }
676
+ );
677
+ }
678
+ outputStream;
679
+ failures = 0;
680
+ suites = {};
681
+ hooks = {};
682
+ tests = {};
683
+ currentSuites = [];
684
+ counts = {
685
+ suites: 0,
686
+ tests: 0,
687
+ hooks: 0,
688
+ passes: 0,
689
+ skipping: 0,
690
+ failures: 0
691
+ };
692
+ retries = 0;
693
+ runnerStat;
694
+ isContentPresent = false;
695
+ specs = [];
696
+ currentSpec;
697
+ /**
698
+ * allows reporter to stale process shutdown process until required sync work
699
+ * is done (e.g. when having to send data to some server or any other async work)
700
+ */
701
+ get isSynchronised() {
702
+ return true;
703
+ }
704
+ /**
705
+ * function to write to reporters output stream
706
+ */
707
+ write(content) {
708
+ if (content) {
709
+ this.isContentPresent = true;
710
+ }
711
+ this.outputStream.write(content);
712
+ }
713
+ /* istanbul ignore next */
714
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
715
+ onRunnerStart(runnerStats) {
716
+ }
717
+ /* istanbul ignore next */
718
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
719
+ onBeforeCommand(commandArgs) {
720
+ }
721
+ /* istanbul ignore next */
722
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
723
+ onAfterCommand(commandArgs) {
724
+ }
725
+ /* istanbul ignore next */
726
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
727
+ onBeforeAssertion(assertionArgs) {
728
+ }
729
+ /* istanbul ignore next */
730
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
731
+ onAfterAssertion(assertionArgs) {
732
+ }
733
+ /* istanbul ignore next */
734
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
735
+ onSuiteStart(suiteStats) {
736
+ }
737
+ /* istanbul ignore next */
738
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
739
+ onHookStart(hookStat) {
740
+ }
741
+ /* istanbul ignore next */
742
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
743
+ onHookEnd(hookStats) {
744
+ }
745
+ /* istanbul ignore next */
746
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
747
+ onTestStart(testStats) {
748
+ }
749
+ /* istanbul ignore next */
750
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
751
+ onTestPass(testStats) {
752
+ }
753
+ /* istanbul ignore next */
754
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
755
+ onTestFail(testStats) {
756
+ }
757
+ /* istanbul ignore next */
758
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
759
+ onTestRetry(testStats) {
760
+ }
761
+ /* istanbul ignore next */
762
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
763
+ onTestSkip(testStats) {
764
+ }
765
+ /* istanbul ignore next */
766
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
767
+ onTestEnd(testStats) {
768
+ }
769
+ /* istanbul ignore next */
770
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
771
+ onSuiteEnd(suiteStats) {
772
+ }
773
+ /* istanbul ignore next */
774
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
775
+ onRunnerEnd(runnerStats) {
776
+ }
777
+ };
778
+ // Annotate the CommonJS export names for ESM import in node:
779
+ 0 && (module.exports = {
780
+ HookStats,
781
+ RunnerStats,
782
+ SuiteStats,
783
+ TestStats
784
+ });