@bigbinary/neeto-playwright-reporter 1.3.13 → 1.3.15
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/index.cjs.js +69 -37
- package/index.cjs.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +68 -36
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -12,8 +12,8 @@ var require$$1$2 = require('tty');
|
|
|
12
12
|
var require$$0$2 = require('os');
|
|
13
13
|
var zlib = require('zlib');
|
|
14
14
|
var EventEmitter = require('events');
|
|
15
|
-
var childProcess = require('child_process');
|
|
16
15
|
var crypto = require('crypto');
|
|
16
|
+
var childProcess = require('child_process');
|
|
17
17
|
|
|
18
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
19
|
|
|
@@ -29,8 +29,8 @@ var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
|
29
29
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
30
30
|
var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
|
|
31
31
|
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
32
|
-
var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
|
|
33
32
|
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
33
|
+
var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
|
|
34
34
|
|
|
35
35
|
function bind(fn, thisArg) {
|
|
36
36
|
return function wrap() {
|
|
@@ -18506,34 +18506,52 @@ const MESSAGES = {
|
|
|
18506
18506
|
},
|
|
18507
18507
|
};
|
|
18508
18508
|
|
|
18509
|
-
const consoleLogFormatted = {
|
|
18510
|
-
bold: (message) => console.log("\x1b[1m", message, "\x1b[0m"),
|
|
18511
|
-
dim: (message) => console.log("\x1b[2m", message, "\x1b[0m"),
|
|
18512
|
-
underline: (message) => console.log("\x1b[4m", message, "\x1b[0m"),
|
|
18513
|
-
invertBackground: (message) => console.log("\x1b[7m", message, "\x1b[0m"),
|
|
18514
|
-
hidden: (message) => console.log("\x1b[8m", message, "\x1b[0m"),
|
|
18515
|
-
error: (message) => console.log("\u001b[31m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18516
|
-
warning: (message) => console.log("\u001b[33m", "\x1b[1m", message, "\x1b[0m", "\u001b[0m"),
|
|
18517
|
-
};
|
|
18518
|
-
const executeCommandLine = ({ command, messageOnError, shouldThrowError = false, logLevel = "warning", }) => {
|
|
18519
|
-
try {
|
|
18520
|
-
return childProcess__default["default"].execSync(command).toString().trim();
|
|
18521
|
-
}
|
|
18522
|
-
catch (err) {
|
|
18523
|
-
if (shouldThrowError) {
|
|
18524
|
-
throw err;
|
|
18525
|
-
}
|
|
18526
|
-
else {
|
|
18527
|
-
consoleLogFormatted[logLevel](messageOnError);
|
|
18528
|
-
}
|
|
18529
|
-
}
|
|
18530
|
-
};
|
|
18531
|
-
|
|
18532
18509
|
const createShardObject = ({ currentShard = 0, status = "running", duration = null, }) => ({
|
|
18533
18510
|
[currentShard]: { status, duration },
|
|
18534
18511
|
});
|
|
18535
18512
|
const waitUntilTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
|
|
18536
18513
|
|
|
18514
|
+
const LOG_LEVEL_FORMATTERS = {
|
|
18515
|
+
bold: "\x1b[1m",
|
|
18516
|
+
dim: "\x1b[2m",
|
|
18517
|
+
underline: "\x1b[4m",
|
|
18518
|
+
invertBackground: "\x1b[7m",
|
|
18519
|
+
hidden: "\x1b[8m",
|
|
18520
|
+
error: "\u001b[31m\x1b[1m",
|
|
18521
|
+
warning: "\u001b[33m\x1b[1m",
|
|
18522
|
+
};
|
|
18523
|
+
|
|
18524
|
+
class ConsoleLogFormatted {
|
|
18525
|
+
constructor() {
|
|
18526
|
+
this.LOG_LEVELS = {
|
|
18527
|
+
info: ["bold", "dim", "underline", "invertBackground", "hidden"],
|
|
18528
|
+
get warning() {
|
|
18529
|
+
return [...this.info, "warning"];
|
|
18530
|
+
},
|
|
18531
|
+
get error() {
|
|
18532
|
+
return [...this.warning, "error"];
|
|
18533
|
+
},
|
|
18534
|
+
};
|
|
18535
|
+
this.shouldPrintMessage = (type) => {
|
|
18536
|
+
var _a;
|
|
18537
|
+
const logLevel = ((_a = process.env.PLAYDASH_LOG_LEVEL) !== null && _a !== void 0 ? _a : "info");
|
|
18538
|
+
const validMethods = this.LOG_LEVELS[logLevel] || [];
|
|
18539
|
+
return validMethods.includes(type);
|
|
18540
|
+
};
|
|
18541
|
+
Object.entries(LOG_LEVEL_FORMATTERS).forEach(([logLevel, ansiFormatter]) => {
|
|
18542
|
+
this.createMethod(logLevel, ansiFormatter);
|
|
18543
|
+
});
|
|
18544
|
+
}
|
|
18545
|
+
createMethod(logLevel, ansiFormatter) {
|
|
18546
|
+
this[logLevel] = (message) => {
|
|
18547
|
+
if (this.shouldPrintMessage(logLevel)) {
|
|
18548
|
+
console.log(`${ansiFormatter}${message}\x1b[0m\u001b[0m`);
|
|
18549
|
+
}
|
|
18550
|
+
};
|
|
18551
|
+
}
|
|
18552
|
+
}
|
|
18553
|
+
var consoleLogFormatted = new ConsoleLogFormatted();
|
|
18554
|
+
|
|
18537
18555
|
const getFileData = (file, contentType, filename) => {
|
|
18538
18556
|
const byte_size = file.byteLength;
|
|
18539
18557
|
const checksum = crypto__default["default"].createHash("md5").update(file).digest("base64");
|
|
@@ -18549,6 +18567,20 @@ const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/
|
|
|
18549
18567
|
const heartbeat = (ciBuildId) => axios.get(`${API_BASE_URL}/reporter/runs/${ciBuildId}/heartbeat`);
|
|
18550
18568
|
const runsApi = { create: create$1, update, heartbeat };
|
|
18551
18569
|
|
|
18570
|
+
const executeCommandLine = ({ command, messageOnError, shouldThrowError = false, logLevel = "warning", }) => {
|
|
18571
|
+
try {
|
|
18572
|
+
return childProcess__default["default"].execSync(command).toString().trim();
|
|
18573
|
+
}
|
|
18574
|
+
catch (err) {
|
|
18575
|
+
if (shouldThrowError) {
|
|
18576
|
+
throw err;
|
|
18577
|
+
}
|
|
18578
|
+
else {
|
|
18579
|
+
consoleLogFormatted[logLevel](messageOnError);
|
|
18580
|
+
}
|
|
18581
|
+
}
|
|
18582
|
+
};
|
|
18583
|
+
|
|
18552
18584
|
const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
|
|
18553
18585
|
const getCurrentCommitSha = () => executeCommandLine({
|
|
18554
18586
|
command: "git rev-parse HEAD",
|
|
@@ -18614,7 +18646,7 @@ class MyReporter {
|
|
|
18614
18646
|
this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
|
|
18615
18647
|
let attempts;
|
|
18616
18648
|
this.totalTestCount = rootSuite.allTests().length;
|
|
18617
|
-
consoleLogFormatted.bold("Started reporting to
|
|
18649
|
+
consoleLogFormatted.bold("Started reporting to NeetoPlaydash 🎭");
|
|
18618
18650
|
try {
|
|
18619
18651
|
const runDetails = {
|
|
18620
18652
|
commit_id: getCurrentCommitSha(),
|
|
@@ -18639,7 +18671,8 @@ class MyReporter {
|
|
|
18639
18671
|
catch (error) {
|
|
18640
18672
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
18641
18673
|
consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : error.message);
|
|
18642
|
-
|
|
18674
|
+
consoleLogFormatted.error(ERRORS.onBegin.failedToInitializeRun);
|
|
18675
|
+
process.exit(1);
|
|
18643
18676
|
}
|
|
18644
18677
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
18645
18678
|
consoleLogFormatted.dim(MESSAGES.onBegin.ciBuildId(this.ciBuildId));
|
|
@@ -18653,15 +18686,15 @@ class MyReporter {
|
|
|
18653
18686
|
};
|
|
18654
18687
|
this.onTestBegin = async ({ id, title }, { retry }) => {
|
|
18655
18688
|
var _a, _b;
|
|
18689
|
+
this.retryAttemptStartedAt = new Date();
|
|
18656
18690
|
this.unreportedAttemptCount++;
|
|
18657
18691
|
consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
|
|
18658
18692
|
try {
|
|
18659
|
-
this.retryAttemptStartedAt = new Date();
|
|
18660
18693
|
while (!((_b = (_a = this.attempts) === null || _a === void 0 ? void 0 : _a[id]) === null || _b === void 0 ? void 0 : _b["0"]))
|
|
18661
18694
|
await waitUntilTimeout(100); // Poll every 100 milliseconds
|
|
18662
18695
|
const attemptsPayload = {
|
|
18663
18696
|
status: "running",
|
|
18664
|
-
started_at:
|
|
18697
|
+
started_at: this.retryAttemptStartedAt.toString(),
|
|
18665
18698
|
shard: this.currentShard,
|
|
18666
18699
|
};
|
|
18667
18700
|
if (retry === 0) {
|
|
@@ -18676,6 +18709,7 @@ class MyReporter {
|
|
|
18676
18709
|
[String(retry)]: attempt_id,
|
|
18677
18710
|
},
|
|
18678
18711
|
};
|
|
18712
|
+
this.testAttemptIds.push(`${history_id}-${attempt_id}`);
|
|
18679
18713
|
}
|
|
18680
18714
|
}
|
|
18681
18715
|
catch (error) {
|
|
@@ -18717,7 +18751,8 @@ class MyReporter {
|
|
|
18717
18751
|
return uploadToS3(file, direct_upload);
|
|
18718
18752
|
}
|
|
18719
18753
|
}));
|
|
18720
|
-
while (!this.attempts[id][retry]
|
|
18754
|
+
while (!(this.attempts[id][retry] ||
|
|
18755
|
+
this.testAttemptIds.includes(`${id}-${this.attempts[id][retry]}`)))
|
|
18721
18756
|
await waitUntilTimeout(100);
|
|
18722
18757
|
this.testResultCalls.push(attemptsApi.update(this.ciBuildId, id, this.attempts[id][retry], testResult));
|
|
18723
18758
|
}
|
|
@@ -18727,16 +18762,13 @@ class MyReporter {
|
|
|
18727
18762
|
}
|
|
18728
18763
|
finally {
|
|
18729
18764
|
this.unreportedAttemptCount--;
|
|
18730
|
-
retry === 0 && this.reportedTestCount++;
|
|
18731
18765
|
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18732
18766
|
}
|
|
18733
18767
|
};
|
|
18734
18768
|
this.onEnd = async ({ status, duration }) => {
|
|
18735
18769
|
var _a, _b;
|
|
18736
18770
|
try {
|
|
18737
|
-
while (!(this.hasRunStarted &&
|
|
18738
|
-
this.totalTestCount === this.reportedTestCount &&
|
|
18739
|
-
this.unreportedAttemptCount === 0))
|
|
18771
|
+
while (!(this.hasRunStarted && this.unreportedAttemptCount === 0))
|
|
18740
18772
|
await waitUntilTimeout(100);
|
|
18741
18773
|
await Promise.allSettled(this.testResultCalls);
|
|
18742
18774
|
await runsApi.update(this.ciBuildId, {
|
|
@@ -18749,8 +18781,8 @@ class MyReporter {
|
|
|
18749
18781
|
}
|
|
18750
18782
|
catch (error) {
|
|
18751
18783
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
18752
|
-
consoleLogFormatted.error((_b = data
|
|
18753
|
-
|
|
18784
|
+
consoleLogFormatted.error((_b = data.error) !== null && _b !== void 0 ? _b : error.message);
|
|
18785
|
+
consoleLogFormatted.error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18754
18786
|
}
|
|
18755
18787
|
finally {
|
|
18756
18788
|
consoleLogFormatted.invertBackground(MESSAGES.onEnd.runReported);
|
|
@@ -18763,9 +18795,9 @@ class MyReporter {
|
|
|
18763
18795
|
this.retryAttemptStartedAt = new Date();
|
|
18764
18796
|
this.testResultCalls = [];
|
|
18765
18797
|
this.totalTestCount = 0;
|
|
18766
|
-
this.reportedTestCount = 0;
|
|
18767
18798
|
this.unreportedAttemptCount = 0;
|
|
18768
18799
|
this.hasRunStarted = false;
|
|
18800
|
+
this.testAttemptIds = [];
|
|
18769
18801
|
process.on("unhandledRejection", error => {
|
|
18770
18802
|
var _a, _b, _c;
|
|
18771
18803
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|