@bigbinary/neeto-playwright-reporter 1.3.18 → 1.3.20

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
@@ -18624,6 +18624,13 @@ const sendHeartBeatSignal = async (ciBuildId) => {
18624
18624
  }
18625
18625
  };
18626
18626
 
18627
+ const evaluateStatus = (outcome, status) => {
18628
+ if (outcome === "flaky")
18629
+ return outcome;
18630
+ else
18631
+ return status;
18632
+ };
18633
+
18627
18634
  const setAuthHeaders = ({ projectKey, apiKey, }) => {
18628
18635
  axios.defaults.headers = {
18629
18636
  ...axios.defaults.headers,
@@ -18646,11 +18653,11 @@ const testEntitiesApi = { create };
18646
18653
  class MyReporter {
18647
18654
  constructor(options) {
18648
18655
  this.onBegin = async (config, rootSuite) => {
18649
- var _a, _b;
18656
+ var _a, _b, _c;
18650
18657
  const shard = config.shard;
18651
18658
  this.config = config;
18652
18659
  this.currentShard = shard === null || shard === void 0 ? void 0 : shard.current;
18653
- let attempts;
18660
+ let attempts = {};
18654
18661
  this.totalTestCount = rootSuite.allTests().length;
18655
18662
  try {
18656
18663
  const runDetails = {
@@ -18674,11 +18681,12 @@ class MyReporter {
18674
18681
  }));
18675
18682
  }
18676
18683
  catch (error) {
18677
- const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
18678
- consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : error.message);
18684
+ const axiosError = error;
18685
+ const data = (_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.data;
18686
+ consoleLogFormatted.error((_b = data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : axiosError.message);
18679
18687
  consoleLogFormatted.error(ERRORS.onBegin.failedToInitializeRun);
18680
18688
  process.kill(process.pid, "SIGKILL");
18681
- process.exit(1);
18689
+ ((_c = axiosError.response) === null || _c === void 0 ? void 0 : _c.status) === 422 && process.exit(1);
18682
18690
  }
18683
18691
  consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
18684
18692
  consoleLogFormatted.dim(MESSAGES.onBegin.ciBuildId(this.ciBuildId));
@@ -18690,21 +18698,21 @@ class MyReporter {
18690
18698
  this.heartbeatInterval = setInterval(async () => await sendHeartBeatSignal(this.ciBuildId), 45000);
18691
18699
  this.attempts = attempts;
18692
18700
  };
18693
- this.onTestBegin = async ({ id, title }, { retry }) => {
18701
+ this.onTestBegin = async ({ id, title, repeatEachIndex }, { retry }) => {
18694
18702
  var _a, _b;
18695
18703
  this.retryAttemptStartedAt = new Date();
18696
18704
  this.unreportedAttemptCount++;
18697
18705
  consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
18698
18706
  try {
18699
- while (!((_b = (_a = this.attempts) === null || _a === void 0 ? void 0 : _a[id]) === null || _b === void 0 ? void 0 : _b["0"]))
18707
+ while (!((_b = (_a = this.attempts) === null || _a === void 0 ? void 0 : _a[id]) === null || _b === void 0 ? void 0 : _b["0-0"]))
18700
18708
  await waitUntilTimeout(100); // Poll every 100 milliseconds
18701
18709
  const attemptsPayload = {
18702
18710
  status: "running",
18703
18711
  started_at: this.retryAttemptStartedAt.toString(),
18704
18712
  shard: this.currentShard,
18705
18713
  };
18706
- if (retry === 0) {
18707
- await attemptsApi.update(this.ciBuildId, id, this.attempts[id]["0"], attemptsPayload);
18714
+ if (retry === 0 && repeatEachIndex === 0) {
18715
+ await attemptsApi.update(this.ciBuildId, id, this.attempts[id]["0-0"], attemptsPayload);
18708
18716
  }
18709
18717
  else {
18710
18718
  const { data: { history_id, attempt_id }, } = await attemptsApi.create(this.ciBuildId, id, attemptsPayload);
@@ -18712,7 +18720,7 @@ class MyReporter {
18712
18720
  ...this.attempts,
18713
18721
  [history_id]: {
18714
18722
  ...this.attempts[history_id],
18715
- [String(retry)]: attempt_id,
18723
+ [`${retry}-${repeatEachIndex}`]: attempt_id,
18716
18724
  },
18717
18725
  };
18718
18726
  this.testAttemptIds.push(`${history_id}-${attempt_id}`);
@@ -18725,13 +18733,20 @@ class MyReporter {
18725
18733
  }
18726
18734
  };
18727
18735
  this.onTestEnd = async (testCase, { status, duration, errors, error, retry, attachments }) => {
18736
+ var _a;
18728
18737
  const completedAt = new Date();
18729
18738
  const errorLocation = error === null || error === void 0 ? void 0 : error.location;
18730
- const { id, title, expectedStatus } = testCase;
18739
+ const { id, title, repeatEachIndex } = testCase;
18740
+ const testOutcome = testCase.outcome();
18741
+ const outcome = {
18742
+ shard: (_a = this.currentShard) !== null && _a !== void 0 ? _a : 0,
18743
+ is_expected: testOutcome === "expected",
18744
+ repeat_each_index: repeatEachIndex,
18745
+ status: evaluateStatus(testOutcome, status),
18746
+ };
18731
18747
  try {
18732
18748
  const testResult = {
18733
- outcome: testCase.outcome(),
18734
- expected_status: expectedStatus,
18749
+ outcome,
18735
18750
  status,
18736
18751
  duration,
18737
18752
  log: errors.map(error => { var _a; return (_a = error.message) !== null && _a !== void 0 ? _a : ""; }).join("\n"),
@@ -18758,10 +18773,10 @@ class MyReporter {
18758
18773
  return uploadToS3(file, direct_upload);
18759
18774
  }
18760
18775
  }));
18761
- while (!(this.attempts[id][retry] ||
18762
- this.testAttemptIds.includes(`${id}-${this.attempts[id][retry]}`)))
18776
+ while (!(this.attempts[id][`${retry}-${repeatEachIndex}`] ||
18777
+ this.testAttemptIds.includes(`${id}-${this.attempts[id][`${retry}-${repeatEachIndex}`]}`)))
18763
18778
  await waitUntilTimeout(100);
18764
- this.testResultCalls.push(attemptsApi.update(this.ciBuildId, id, this.attempts[id][retry], testResult));
18779
+ this.testResultCalls.push(attemptsApi.update(this.ciBuildId, id, this.attempts[id][`${retry}-${repeatEachIndex}`], testResult));
18765
18780
  }
18766
18781
  catch (error) {
18767
18782
  consoleLogFormatted.error(error.message);