ScuttleBot

1
"use strict";
2
var __defProp = Object.defineProperty;
3
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
var __getOwnPropNames = Object.getOwnPropertyNames;
5
var __hasOwnProp = Object.prototype.hasOwnProperty;
6
var __export = (target, all) => {
7
for (var name in all)
8
__defProp(target, name, { get: all[name], enumerable: true });
9
};
10
var __copyProps = (to, from, except, desc) => {
11
if (from && typeof from === "object" || typeof from === "function") {
12
for (let key of __getOwnPropNames(from))
13
if (!__hasOwnProp.call(to, key) && key !== except)
14
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
}
16
return to;
17
};
18
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
var line_exports = {};
20
__export(line_exports, {
21
default: () => line_default
22
});
23
module.exports = __toCommonJS(line_exports);
24
var import_base = require("./base");
25
class LineReporter extends import_base.TerminalReporter {
26
constructor() {
27
super(...arguments);
28
this._current = 0;
29
this._failures = 0;
30
this._didBegin = false;
31
}
32
onBegin(suite) {
33
super.onBegin(suite);
34
const startingMessage = this.generateStartingMessage();
35
if (startingMessage) {
36
this.writeLine(startingMessage);
37
this.writeLine();
38
}
39
this._didBegin = true;
40
}
41
onStdOut(chunk, test, result) {
42
super.onStdOut(chunk, test, result);
43
this._dumpToStdio(test, chunk, this.screen.stdout);
44
}
45
onStdErr(chunk, test, result) {
46
super.onStdErr(chunk, test, result);
47
this._dumpToStdio(test, chunk, this.screen.stderr);
48
}
49
_dumpToStdio(test, chunk, stream) {
50
if (this.config.quiet)
51
return;
52
if (!process.env.PW_TEST_DEBUG_REPORTERS)
53
stream.write(`\x1B[1A\x1B[2K`);
54
if (test && this._lastTest !== test) {
55
const title = this.screen.colors.dim(this.formatTestTitle(test));
56
stream.write(this.fitToScreen(title) + `
57
`);
58
this._lastTest = test;
59
}
60
stream.write(chunk);
61
if (chunk[chunk.length - 1] !== "\n")
62
this.writeLine();
63
this.writeLine();
64
}
65
onTestBegin(test, result) {
66
++this._current;
67
this._updateLine(test, result, void 0);
68
}
69
onStepBegin(test, result, step) {
70
if (this.screen.isTTY && step.category === "test.step")
71
this._updateLine(test, result, step);
72
}
73
onStepEnd(test, result, step) {
74
if (this.screen.isTTY && step.category === "test.step")
75
this._updateLine(test, result, step.parent);
76
}
77
async onTestPaused(test, result) {
78
if (!process.stdin.isTTY && !process.env.PW_TEST_DEBUG_REPORTERS)
79
return;
80
if (!process.env.PW_TEST_DEBUG_REPORTERS)
81
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
82
if (test.outcome() === "unexpected") {
83
this.writeLine(this.screen.colors.red(this.formatTestHeader(test, { indent: " ", index: ++this._failures })));
84
this.writeLine(this.formatResultErrors(test, result));
85
(0, import_base.markErrorsAsReported)(result);
86
this.writeLine(this.screen.colors.yellow(` Paused on error. Press Ctrl+C to end.`) + "\n\n");
87
} else {
88
this.writeLine(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
89
this.writeLine(this.screen.colors.yellow(` Paused at test end. Press Ctrl+C to end.`) + "\n\n");
90
}
91
this._updateLine(test, result, void 0);
92
await new Promise(() => {
93
});
94
}
95
onTestEnd(test, result) {
96
super.onTestEnd(test, result);
97
if (!this.willRetry(test) && (test.outcome() === "flaky" || test.outcome() === "unexpected" || result.status === "interrupted")) {
98
if (!process.env.PW_TEST_DEBUG_REPORTERS)
99
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
100
this.writeLine(this.formatFailure(test, ++this._failures));
101
this.writeLine();
102
}
103
}
104
_updateLine(test, result, step) {
105
const retriesPrefix = this.totalTestCount < this._current ? ` (retries)` : ``;
106
const prefix = `[${this._current}/${this.totalTestCount}]${retriesPrefix} `;
107
const currentRetrySuffix = result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : "";
108
const title = this.formatTestTitle(test, step) + currentRetrySuffix;
109
if (process.env.PW_TEST_DEBUG_REPORTERS)
110
this.screen.stdout.write(`${prefix + title}
111
`);
112
else
113
this.screen.stdout.write(`\x1B[1A\x1B[2K${prefix + this.fitToScreen(title, prefix)}
114
`);
115
}
116
onError(error) {
117
super.onError(error);
118
const message = this.formatError(error).message + "\n";
119
if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin)
120
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
121
this.screen.stdout.write(message);
122
this.writeLine();
123
}
124
async onEnd(result) {
125
if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin)
126
this.screen.stdout.write(`\x1B[1A\x1B[2K`);
127
await super.onEnd(result);
128
this.epilogue(false);
129
}
130
}
131
var line_default = LineReporter;
132

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button