@bigbinary/neeto-playwright-reporter 1.3.6 → 1.3.8

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.d.ts CHANGED
@@ -15,10 +15,11 @@ declare class MyReporter implements Reporter {
15
15
  testResultCalls: Promise<unknown>[];
16
16
  totalTestCount: number;
17
17
  reportedTestCount: number;
18
+ unreportedAttemptCount: number;
18
19
  constructor(options: ReporterOptionParams);
19
20
  onBegin: (config: FullConfig, rootSuite: Suite) => Promise<void>;
20
21
  onTestBegin: ({ id, title }: TestCase, { retry }: TestResult) => Promise<void>;
21
- onTestEnd: (testCase: TestCase, { status, duration, errors, retry, attachments }: TestResult) => Promise<void>;
22
+ onTestEnd: (testCase: TestCase, { status, duration, errors, error, retry, attachments }: TestResult) => Promise<void>;
22
23
  onEnd: ({ status, duration }: FullResult) => Promise<void>;
23
24
  }
24
25
 
package/index.js CHANGED
@@ -18451,6 +18451,7 @@ const uploadToS3 = (data, { url, headers }) => axios.put(url, data, { headers })
18451
18451
 
18452
18452
  const ERRORS = {
18453
18453
  onBegin: {
18454
+ noTestsToReport: "No tests to report",
18454
18455
  failedToGetCommitSha: "Failed to get current commit SHA.",
18455
18456
  failedToGetBranch: "Failed to get current branch.",
18456
18457
  failedToGetCommitMessage: "Failed to get current commit message.",
@@ -18469,7 +18470,7 @@ const ERRORS = {
18469
18470
 
18470
18471
  const MESSAGES = {
18471
18472
  onBegin: {
18472
- testStarted: "Run has started reporting to neetoPlaywrightReporter",
18473
+ testStarted: "Run has started reporting to neetoPlaydash",
18473
18474
  ciBuildId: (currentCiBuildId) => `CI BUILD ID: ${currentCiBuildId}`,
18474
18475
  totalShards: (totalShards) => `Total shards: ${totalShards}`,
18475
18476
  currentShard: (currentShard) => `Current shard: ${currentShard}`,
@@ -18480,6 +18481,9 @@ const MESSAGES = {
18480
18481
  onTestEnd: {
18481
18482
  reportedTest: (title) => `Reported ${title} to neetoPlaywrightReporter`,
18482
18483
  },
18484
+ onEnd: {
18485
+ runReported: "Run completed and reported to neetoPlaydash 🎉",
18486
+ },
18483
18487
  };
18484
18488
 
18485
18489
  const consoleLogFormatted = {
@@ -18583,6 +18587,10 @@ class MyReporter {
18583
18587
  const shard = config.shard;
18584
18588
  let attempts;
18585
18589
  this.totalTestCount = rootSuite.allTests().length;
18590
+ if (this.totalTestCount === 0) {
18591
+ consoleLogFormatted.error(ERRORS.onBegin.noTestsToReport);
18592
+ process.exit(0);
18593
+ }
18586
18594
  try {
18587
18595
  const runDetails = {
18588
18596
  commit_id: getCurrentCommitSha(),
@@ -18615,6 +18623,7 @@ class MyReporter {
18615
18623
  };
18616
18624
  this.onTestBegin = async ({ id, title }, { retry }) => {
18617
18625
  var _a, _b;
18626
+ this.unreportedAttemptCount++;
18618
18627
  consoleLogFormatted.invertBackground(MESSAGES.onTestBegin.startingTest(title));
18619
18628
  try {
18620
18629
  this.retryAttemptStartedAt = new Date();
@@ -18644,8 +18653,9 @@ class MyReporter {
18644
18653
  consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
18645
18654
  }
18646
18655
  };
18647
- this.onTestEnd = async (testCase, { status, duration, errors, retry, attachments }) => {
18656
+ this.onTestEnd = async (testCase, { status, duration, errors, error, retry, attachments }) => {
18648
18657
  const completedAt = new Date();
18658
+ const errorLocation = error === null || error === void 0 ? void 0 : error.location;
18649
18659
  const { id, title, expectedStatus } = testCase;
18650
18660
  try {
18651
18661
  const testResult = {
@@ -18658,6 +18668,7 @@ class MyReporter {
18658
18668
  videos: [],
18659
18669
  traces: [],
18660
18670
  completed_at: completedAt.toString(),
18671
+ error_snippet: `# ${errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.file} (${errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line}:${errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.column}) \n\n\n ${error === null || error === void 0 ? void 0 : error.snippet}`,
18661
18672
  };
18662
18673
  consoleLogFormatted.underline(title);
18663
18674
  await Promise.all(attachments.map(async ({ name, path, body, contentType, }) => {
@@ -18677,21 +18688,23 @@ class MyReporter {
18677
18688
  while (!this.attempts[id][retry])
18678
18689
  await waitUntilTimeout(100);
18679
18690
  this.testResultCalls.push(attemptsApi.update(this.ciBuildId, id, this.attempts[id][retry], testResult));
18680
- consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
18681
18691
  }
18682
18692
  catch (error) {
18683
18693
  consoleLogFormatted.error(error.message);
18684
18694
  consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
18685
18695
  }
18686
18696
  finally {
18697
+ this.unreportedAttemptCount--;
18687
18698
  retry === 0 && this.reportedTestCount++;
18699
+ consoleLogFormatted.invertBackground(MESSAGES.onTestEnd.reportedTest(title));
18688
18700
  }
18689
18701
  };
18690
18702
  this.onEnd = async ({ status, duration }) => {
18691
18703
  try {
18692
- await Promise.allSettled(this.testResultCalls);
18693
- while (this.totalTestCount !== this.reportedTestCount)
18704
+ while (this.totalTestCount !== this.reportedTestCount &&
18705
+ this.unreportedAttemptCount !== 0)
18694
18706
  await waitUntilTimeout(100);
18707
+ await Promise.allSettled(this.testResultCalls);
18695
18708
  await runsApi.update(this.ciBuildId, {
18696
18709
  shards: createShardObject({
18697
18710
  currentShard: this.currentShard,
@@ -18704,6 +18717,9 @@ class MyReporter {
18704
18717
  consoleLogFormatted.error(error.message);
18705
18718
  throw new Error(ERRORS.onEnd.failedToReportRunStatus);
18706
18719
  }
18720
+ finally {
18721
+ consoleLogFormatted.invertBackground(MESSAGES.onEnd.runReported);
18722
+ }
18707
18723
  };
18708
18724
  initializeAxios(options);
18709
18725
  this.attempts = {};
@@ -18712,6 +18728,7 @@ class MyReporter {
18712
18728
  this.testResultCalls = [];
18713
18729
  this.totalTestCount = 0;
18714
18730
  this.reportedTestCount = 0;
18731
+ this.unreportedAttemptCount = 0;
18715
18732
  process.on("unhandledRejection", error => {
18716
18733
  var _a;
18717
18734
  consoleLogFormatted.error((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : JSON.stringify(error));