@bigbinary/neeto-playwright-reporter 1.3.15 → 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 CHANGED
@@ -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: "Run has started reporting to neetoPlaydash",
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,10 +18504,10 @@ const MESSAGES = {
18499
18504
  startingTest: (titlePath) => `Starting ${titlePath}`,
18500
18505
  },
18501
18506
  onTestEnd: {
18502
- reportedTest: (title) => `Reported ${title} to neetoPlaydash`,
18507
+ reportedTest: (title) => `Reported ${title} to NeetoPlaydash`,
18503
18508
  },
18504
18509
  onEnd: {
18505
- runReported: "Run completed and reported to neetoPlaydash 🎉",
18510
+ runReported: "Run completed and reported to NeetoPlaydash 🎉",
18506
18511
  },
18507
18512
  };
18508
18513
 
@@ -18518,13 +18523,14 @@ const LOG_LEVEL_FORMATTERS = {
18518
18523
  invertBackground: "\x1b[7m",
18519
18524
  hidden: "\x1b[8m",
18520
18525
  error: "\u001b[31m\x1b[1m",
18526
+ redText: "\u001b[31m\x1b[1m", // Same ANSI style as error but in log level printing important errors
18521
18527
  warning: "\u001b[33m\x1b[1m",
18522
18528
  };
18523
18529
 
18524
18530
  class ConsoleLogFormatted {
18525
18531
  constructor() {
18526
18532
  this.LOG_LEVELS = {
18527
- info: ["bold", "dim", "underline", "invertBackground", "hidden"],
18533
+ info: ["bold", "dim", "underline", "invertBackground", "hidden", "redText"],
18528
18534
  get warning() {
18529
18535
  return [...this.info, "warning"];
18530
18536
  },
@@ -18612,7 +18618,7 @@ const sendHeartBeatSignal = async (ciBuildId) => {
18612
18618
  await runsApi.heartbeat(ciBuildId);
18613
18619
  }
18614
18620
  catch (error) {
18615
- console.log(error.message);
18621
+ consoleLogFormatted.redText(error.message);
18616
18622
  consoleLogFormatted.error(ERRORS.heartbeat.stopped);
18617
18623
  process.exit(1);
18618
18624
  }
@@ -18646,7 +18652,6 @@ class MyReporter {
18646
18652
  this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
18647
18653
  let attempts;
18648
18654
  this.totalTestCount = rootSuite.allTests().length;
18649
- consoleLogFormatted.bold("Started reporting to NeetoPlaydash 🎭");
18650
18655
  try {
18651
18656
  const runDetails = {
18652
18657
  commit_id: getCurrentCommitSha(),
@@ -18672,6 +18677,7 @@ class MyReporter {
18672
18677
  const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
18673
18678
  consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : error.message);
18674
18679
  consoleLogFormatted.error(ERRORS.onBegin.failedToInitializeRun);
18680
+ process.kill(process.pid, "SIGKILL");
18675
18681
  process.exit(1);
18676
18682
  }
18677
18683
  consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
@@ -18715,6 +18721,7 @@ class MyReporter {
18715
18721
  catch (error) {
18716
18722
  consoleLogFormatted.error(error.message);
18717
18723
  consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
18724
+ await sendHeartBeatSignal(this.ciBuildId);
18718
18725
  }
18719
18726
  };
18720
18727
  this.onTestEnd = async (testCase, { status, duration, errors, error, retry, attachments }) => {
@@ -18739,7 +18746,7 @@ class MyReporter {
18739
18746
  consoleLogFormatted.underline(title);
18740
18747
  await Promise.all(attachments.map(async ({ name, path, body, contentType, }) => {
18741
18748
  consoleLogFormatted.dim(`${name}: ${path}`);
18742
- if (["screenshot", "video", "trace"].includes(name)) {
18749
+ if (VALID_ASSET_TYPES.includes(name)) {
18743
18750
  const buffer = path ? require$$6__default["default"].readFileSync(path) : body;
18744
18751
  const fileName = path
18745
18752
  ? path.split("/").slice(-1)[0]
@@ -18759,6 +18766,7 @@ class MyReporter {
18759
18766
  catch (error) {
18760
18767
  consoleLogFormatted.error(error.message);
18761
18768
  consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
18769
+ await sendHeartBeatSignal(this.ciBuildId);
18762
18770
  }
18763
18771
  finally {
18764
18772
  this.unreportedAttemptCount--;
@@ -18798,9 +18806,10 @@ class MyReporter {
18798
18806
  this.unreportedAttemptCount = 0;
18799
18807
  this.hasRunStarted = false;
18800
18808
  this.testAttemptIds = [];
18801
- process.on("unhandledRejection", error => {
18809
+ process.on("unhandledRejection", async (error) => {
18802
18810
  var _a, _b, _c;
18803
18811
  const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
18812
+ await sendHeartBeatSignal(this.ciBuildId);
18804
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));
18805
18814
  });
18806
18815
  }