@bigbinary/neeto-playwright-reporter 1.3.14 → 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 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 neetoPlaydash 🎭");
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
- throw new Error(ERRORS.onBegin.failedToInitializeRun);
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));
@@ -18729,16 +18762,13 @@ class MyReporter {
18729
18762
  }
18730
18763
  finally {
18731
18764
  this.unreportedAttemptCount--;
18732
- retry === 0 && this.reportedTestCount++;
18733
18765
  consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
18734
18766
  }
18735
18767
  };
18736
18768
  this.onEnd = async ({ status, duration }) => {
18737
18769
  var _a, _b;
18738
18770
  try {
18739
- while (!(this.hasRunStarted &&
18740
- this.totalTestCount === this.reportedTestCount &&
18741
- this.unreportedAttemptCount === 0))
18771
+ while (!(this.hasRunStarted && this.unreportedAttemptCount === 0))
18742
18772
  await waitUntilTimeout(100);
18743
18773
  await Promise.allSettled(this.testResultCalls);
18744
18774
  await runsApi.update(this.ciBuildId, {
@@ -18751,8 +18781,8 @@ class MyReporter {
18751
18781
  }
18752
18782
  catch (error) {
18753
18783
  const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
18754
- consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : error.message);
18755
- throw new Error(ERRORS.onEnd.failedToReportRunStatus);
18784
+ consoleLogFormatted.error((_b = data.error) !== null && _b !== void 0 ? _b : error.message);
18785
+ consoleLogFormatted.error(ERRORS.onEnd.failedToReportRunStatus);
18756
18786
  }
18757
18787
  finally {
18758
18788
  consoleLogFormatted.invertBackground(MESSAGES.onEnd.runReported);
@@ -18765,7 +18795,6 @@ class MyReporter {
18765
18795
  this.retryAttemptStartedAt = new Date();
18766
18796
  this.testResultCalls = [];
18767
18797
  this.totalTestCount = 0;
18768
- this.reportedTestCount = 0;
18769
18798
  this.unreportedAttemptCount = 0;
18770
18799
  this.hasRunStarted = false;
18771
18800
  this.testAttemptIds = [];