@bigbinary/neeto-playwright-reporter 1.3.14 → 1.3.16
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 +78 -40
- package/index.cjs.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +77 -39
- 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() {
|
|
@@ -18468,6 +18468,8 @@ const getDirectUploadURL = (payload) => axios.post(`${API_BASE_URL}/reporter/dir
|
|
|
18468
18468
|
});
|
|
18469
18469
|
const uploadToS3 = (data, { url, headers }) => axios.put(url, data, { headers });
|
|
18470
18470
|
|
|
18471
|
+
const VALID_ASSET_TYPES = ["screenshot", "video", "trace"];
|
|
18472
|
+
|
|
18471
18473
|
const ERRORS = {
|
|
18472
18474
|
onBegin: {
|
|
18473
18475
|
noTestsToReport: "No tests to report",
|
|
@@ -18483,6 +18485,9 @@ const ERRORS = {
|
|
|
18483
18485
|
onEnd: {
|
|
18484
18486
|
failedToReportRunStatus: "Failed to report run status",
|
|
18485
18487
|
},
|
|
18488
|
+
onTestEnd: {
|
|
18489
|
+
attemptAlreadyReported: "Attempt was already reported",
|
|
18490
|
+
},
|
|
18486
18491
|
heartbeat: {
|
|
18487
18492
|
stopped: "Run was stopped at the reporter",
|
|
18488
18493
|
},
|
|
@@ -18490,7 +18495,7 @@ const ERRORS = {
|
|
|
18490
18495
|
|
|
18491
18496
|
const MESSAGES = {
|
|
18492
18497
|
onBegin: {
|
|
18493
|
-
testStarted: "
|
|
18498
|
+
testStarted: "Started reporting to NeetoPlaydash 🎭",
|
|
18494
18499
|
ciBuildId: (currentCiBuildId) => `CI BUILD ID: ${currentCiBuildId}`,
|
|
18495
18500
|
totalShards: (totalShards) => `Total shards: ${totalShards}`,
|
|
18496
18501
|
currentShard: (currentShard) => `Current shard: ${currentShard}`,
|
|
@@ -18499,41 +18504,60 @@ const MESSAGES = {
|
|
|
18499
18504
|
startingTest: (titlePath) => `Starting ${titlePath}`,
|
|
18500
18505
|
},
|
|
18501
18506
|
onTestEnd: {
|
|
18502
|
-
reportedTest: (title) => `Reported ${title} to
|
|
18507
|
+
reportedTest: (title) => `Reported ${title} to NeetoPlaydash`,
|
|
18503
18508
|
},
|
|
18504
18509
|
onEnd: {
|
|
18505
|
-
runReported: "Run completed and reported to
|
|
18510
|
+
runReported: "Run completed and reported to NeetoPlaydash 🎉",
|
|
18506
18511
|
},
|
|
18507
18512
|
};
|
|
18508
18513
|
|
|
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
18514
|
const createShardObject = ({ currentShard = 0, status = "running", duration = null, }) => ({
|
|
18533
18515
|
[currentShard]: { status, duration },
|
|
18534
18516
|
});
|
|
18535
18517
|
const waitUntilTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
|
|
18536
18518
|
|
|
18519
|
+
const LOG_LEVEL_FORMATTERS = {
|
|
18520
|
+
bold: "\x1b[1m",
|
|
18521
|
+
dim: "\x1b[2m",
|
|
18522
|
+
underline: "\x1b[4m",
|
|
18523
|
+
invertBackground: "\x1b[7m",
|
|
18524
|
+
hidden: "\x1b[8m",
|
|
18525
|
+
error: "\u001b[31m\x1b[1m",
|
|
18526
|
+
redText: "\u001b[31m\x1b[1m", // Same ANSI style as error but in log level printing important errors
|
|
18527
|
+
warning: "\u001b[33m\x1b[1m",
|
|
18528
|
+
};
|
|
18529
|
+
|
|
18530
|
+
class ConsoleLogFormatted {
|
|
18531
|
+
constructor() {
|
|
18532
|
+
this.LOG_LEVELS = {
|
|
18533
|
+
info: ["bold", "dim", "underline", "invertBackground", "hidden", "redText"],
|
|
18534
|
+
get warning() {
|
|
18535
|
+
return [...this.info, "warning"];
|
|
18536
|
+
},
|
|
18537
|
+
get error() {
|
|
18538
|
+
return [...this.warning, "error"];
|
|
18539
|
+
},
|
|
18540
|
+
};
|
|
18541
|
+
this.shouldPrintMessage = (type) => {
|
|
18542
|
+
var _a;
|
|
18543
|
+
const logLevel = ((_a = process.env.PLAYDASH_LOG_LEVEL) !== null && _a !== void 0 ? _a : "info");
|
|
18544
|
+
const validMethods = this.LOG_LEVELS[logLevel] || [];
|
|
18545
|
+
return validMethods.includes(type);
|
|
18546
|
+
};
|
|
18547
|
+
Object.entries(LOG_LEVEL_FORMATTERS).forEach(([logLevel, ansiFormatter]) => {
|
|
18548
|
+
this.createMethod(logLevel, ansiFormatter);
|
|
18549
|
+
});
|
|
18550
|
+
}
|
|
18551
|
+
createMethod(logLevel, ansiFormatter) {
|
|
18552
|
+
this[logLevel] = (message) => {
|
|
18553
|
+
if (this.shouldPrintMessage(logLevel)) {
|
|
18554
|
+
console.log(`${ansiFormatter}${message}\x1b[0m\u001b[0m`);
|
|
18555
|
+
}
|
|
18556
|
+
};
|
|
18557
|
+
}
|
|
18558
|
+
}
|
|
18559
|
+
var consoleLogFormatted = new ConsoleLogFormatted();
|
|
18560
|
+
|
|
18537
18561
|
const getFileData = (file, contentType, filename) => {
|
|
18538
18562
|
const byte_size = file.byteLength;
|
|
18539
18563
|
const checksum = crypto__default["default"].createHash("md5").update(file).digest("base64");
|
|
@@ -18549,6 +18573,20 @@ const update = (ciBuildId, payload) => axios.put(`${API_BASE_URL}/reporter/runs/
|
|
|
18549
18573
|
const heartbeat = (ciBuildId) => axios.get(`${API_BASE_URL}/reporter/runs/${ciBuildId}/heartbeat`);
|
|
18550
18574
|
const runsApi = { create: create$1, update, heartbeat };
|
|
18551
18575
|
|
|
18576
|
+
const executeCommandLine = ({ command, messageOnError, shouldThrowError = false, logLevel = "warning", }) => {
|
|
18577
|
+
try {
|
|
18578
|
+
return childProcess__default["default"].execSync(command).toString().trim();
|
|
18579
|
+
}
|
|
18580
|
+
catch (err) {
|
|
18581
|
+
if (shouldThrowError) {
|
|
18582
|
+
throw err;
|
|
18583
|
+
}
|
|
18584
|
+
else {
|
|
18585
|
+
consoleLogFormatted[logLevel](messageOnError);
|
|
18586
|
+
}
|
|
18587
|
+
}
|
|
18588
|
+
};
|
|
18589
|
+
|
|
18552
18590
|
const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
|
|
18553
18591
|
const getCurrentCommitSha = () => executeCommandLine({
|
|
18554
18592
|
command: "git rev-parse HEAD",
|
|
@@ -18580,7 +18618,7 @@ const sendHeartBeatSignal = async (ciBuildId) => {
|
|
|
18580
18618
|
await runsApi.heartbeat(ciBuildId);
|
|
18581
18619
|
}
|
|
18582
18620
|
catch (error) {
|
|
18583
|
-
|
|
18621
|
+
consoleLogFormatted.redText(error.message);
|
|
18584
18622
|
consoleLogFormatted.error(ERRORS.heartbeat.stopped);
|
|
18585
18623
|
process.exit(1);
|
|
18586
18624
|
}
|
|
@@ -18614,7 +18652,6 @@ class MyReporter {
|
|
|
18614
18652
|
this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
|
|
18615
18653
|
let attempts;
|
|
18616
18654
|
this.totalTestCount = rootSuite.allTests().length;
|
|
18617
|
-
consoleLogFormatted.bold("Started reporting to neetoPlaydash 🎭");
|
|
18618
18655
|
try {
|
|
18619
18656
|
const runDetails = {
|
|
18620
18657
|
commit_id: getCurrentCommitSha(),
|
|
@@ -18639,7 +18676,9 @@ class MyReporter {
|
|
|
18639
18676
|
catch (error) {
|
|
18640
18677
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
18641
18678
|
consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : error.message);
|
|
18642
|
-
|
|
18679
|
+
consoleLogFormatted.error(ERRORS.onBegin.failedToInitializeRun);
|
|
18680
|
+
process.kill(process.pid, "SIGKILL");
|
|
18681
|
+
process.exit(1);
|
|
18643
18682
|
}
|
|
18644
18683
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
18645
18684
|
consoleLogFormatted.dim(MESSAGES.onBegin.ciBuildId(this.ciBuildId));
|
|
@@ -18682,6 +18721,7 @@ class MyReporter {
|
|
|
18682
18721
|
catch (error) {
|
|
18683
18722
|
consoleLogFormatted.error(error.message);
|
|
18684
18723
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18724
|
+
await sendHeartBeatSignal(this.ciBuildId);
|
|
18685
18725
|
}
|
|
18686
18726
|
};
|
|
18687
18727
|
this.onTestEnd = async (testCase, { status, duration, errors, error, retry, attachments }) => {
|
|
@@ -18706,7 +18746,7 @@ class MyReporter {
|
|
|
18706
18746
|
consoleLogFormatted.underline(title);
|
|
18707
18747
|
await Promise.all(attachments.map(async ({ name, path, body, contentType, }) => {
|
|
18708
18748
|
consoleLogFormatted.dim(`${name}: ${path}`);
|
|
18709
|
-
if (
|
|
18749
|
+
if (VALID_ASSET_TYPES.includes(name)) {
|
|
18710
18750
|
const buffer = path ? require$$6__default["default"].readFileSync(path) : body;
|
|
18711
18751
|
const fileName = path
|
|
18712
18752
|
? path.split("/").slice(-1)[0]
|
|
@@ -18726,19 +18766,17 @@ class MyReporter {
|
|
|
18726
18766
|
catch (error) {
|
|
18727
18767
|
consoleLogFormatted.error(error.message);
|
|
18728
18768
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18769
|
+
await sendHeartBeatSignal(this.ciBuildId);
|
|
18729
18770
|
}
|
|
18730
18771
|
finally {
|
|
18731
18772
|
this.unreportedAttemptCount--;
|
|
18732
|
-
retry === 0 && this.reportedTestCount++;
|
|
18733
18773
|
consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
|
|
18734
18774
|
}
|
|
18735
18775
|
};
|
|
18736
18776
|
this.onEnd = async ({ status, duration }) => {
|
|
18737
18777
|
var _a, _b;
|
|
18738
18778
|
try {
|
|
18739
|
-
while (!(this.hasRunStarted &&
|
|
18740
|
-
this.totalTestCount === this.reportedTestCount &&
|
|
18741
|
-
this.unreportedAttemptCount === 0))
|
|
18779
|
+
while (!(this.hasRunStarted && this.unreportedAttemptCount === 0))
|
|
18742
18780
|
await waitUntilTimeout(100);
|
|
18743
18781
|
await Promise.allSettled(this.testResultCalls);
|
|
18744
18782
|
await runsApi.update(this.ciBuildId, {
|
|
@@ -18751,8 +18789,8 @@ class MyReporter {
|
|
|
18751
18789
|
}
|
|
18752
18790
|
catch (error) {
|
|
18753
18791
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
18754
|
-
consoleLogFormatted.error((_b = data
|
|
18755
|
-
|
|
18792
|
+
consoleLogFormatted.error((_b = data.error) !== null && _b !== void 0 ? _b : error.message);
|
|
18793
|
+
consoleLogFormatted.error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18756
18794
|
}
|
|
18757
18795
|
finally {
|
|
18758
18796
|
consoleLogFormatted.invertBackground(MESSAGES.onEnd.runReported);
|
|
@@ -18765,13 +18803,13 @@ class MyReporter {
|
|
|
18765
18803
|
this.retryAttemptStartedAt = new Date();
|
|
18766
18804
|
this.testResultCalls = [];
|
|
18767
18805
|
this.totalTestCount = 0;
|
|
18768
|
-
this.reportedTestCount = 0;
|
|
18769
18806
|
this.unreportedAttemptCount = 0;
|
|
18770
18807
|
this.hasRunStarted = false;
|
|
18771
18808
|
this.testAttemptIds = [];
|
|
18772
|
-
process.on("unhandledRejection", error => {
|
|
18809
|
+
process.on("unhandledRejection", async (error) => {
|
|
18773
18810
|
var _a, _b, _c;
|
|
18774
18811
|
const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
18812
|
+
await sendHeartBeatSignal(this.ciBuildId);
|
|
18775
18813
|
consoleLogFormatted.error((_c = (_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : error.message) !== null && _c !== void 0 ? _c : JSON.stringify(error));
|
|
18776
18814
|
});
|
|
18777
18815
|
}
|