@arghajit/dummy 0.1.2-beta-7 → 0.1.2-beta-9

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.
@@ -23,13 +23,16 @@ export declare class PlaywrightPulseReporter implements Reporter {
23
23
  private _getBaseTestId;
24
24
  private _getStatusOrder;
25
25
  /**
26
- * Modified: Groups all run attempts for a single logical test case and updates flaky status.
27
- * This ensures that tests with multiple retries are counted as single test case
28
- * while preserving all retry data in the JSON report.
26
+ * Groups all run attempts for a single logical test case and creates consolidated test results.
27
+ * This matches Playwright's default structure where retry attempts are grouped under one test entry.
29
28
  * @param allAttempts An array of all individual test run attempts.
30
- * @returns An array of ConsolidatedTestResult objects, where each object represents one logical test and contains an array of all its runs.
29
+ * @returns An array of ConsolidatedTestResult objects, where each object represents one logical test with all its retry attempts.
31
30
  */
32
31
  private _getFinalizedResults;
32
+ /**
33
+ * Helper method to get summary statistics from consolidated results
34
+ */
35
+ private _getSummaryStats;
33
36
  onError(error: any): void;
34
37
  private _getEnvDetails;
35
38
  private _writeShardResults;
@@ -39,10 +39,7 @@ const path = __importStar(require("path"));
39
39
  const crypto_1 = require("crypto");
40
40
  const ua_parser_js_1 = require("ua-parser-js");
41
41
  const os = __importStar(require("os"));
42
- const convertStatus = (status, testCase, retryCount = 0) => {
43
- if (status === "passed" && retryCount > 0) {
44
- return "flaky";
45
- }
42
+ const convertStatus = (status, testCase) => {
46
43
  if ((testCase === null || testCase === void 0 ? void 0 : testCase.expectedStatus) === "failed") {
47
44
  if (status === "passed")
48
45
  return "flaky";
@@ -165,7 +162,7 @@ class PlaywrightPulseReporter {
165
162
  }
166
163
  return finalString.trim();
167
164
  }
168
- async processStep(step, testId, browserDetails, testCase, retryCount = 0) {
165
+ async processStep(step, testId, browserDetails, testCase) {
169
166
  var _a, _b, _c, _d;
170
167
  let stepStatus = "passed";
171
168
  let errorMessage = ((_a = step.error) === null || _a === void 0 ? void 0 : _a.message) || undefined;
@@ -173,7 +170,7 @@ class PlaywrightPulseReporter {
173
170
  stepStatus = "skipped";
174
171
  }
175
172
  else {
176
- stepStatus = convertStatus(step.error ? "failed" : "passed", testCase, retryCount);
173
+ stepStatus = convertStatus(step.error ? "failed" : "passed", testCase);
177
174
  }
178
175
  const duration = step.duration;
179
176
  const startTime = new Date(step.startTime);
@@ -206,13 +203,13 @@ class PlaywrightPulseReporter {
206
203
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
207
204
  const project = (_a = test.parent) === null || _a === void 0 ? void 0 : _a.project();
208
205
  const browserDetails = this.getBrowserDetails(test);
209
- const testStatus = convertStatus(result.status, test, result.retry);
206
+ const testStatus = convertStatus(result.status, test);
210
207
  const startTime = new Date(result.startTime);
211
208
  const endTime = new Date(startTime.getTime() + result.duration);
212
209
  const processAllSteps = async (steps) => {
213
210
  let processed = [];
214
211
  for (const step of steps) {
215
- const processedStep = await this.processStep(step, test.id, browserDetails, test, result.retry);
212
+ const processedStep = await this.processStep(step, test.id, browserDetails, test);
216
213
  processed.push(processedStep);
217
214
  if (step.steps && step.steps.length > 0) {
218
215
  processedStep.steps = await processAllSteps(step.steps);
@@ -244,9 +241,8 @@ class PlaywrightPulseReporter {
244
241
  ? JSON.stringify(this.config.metadata)
245
242
  : undefined,
246
243
  };
247
- const testIdWithRetries = `${test.id}-${result.retry}`;
248
244
  const pulseResult = {
249
- id: testIdWithRetries, // Modified: Use retry number instead of "run-X"
245
+ id: test.id, // Fixed: Use consistent test ID across all retries
250
246
  runId: this.currentRunId, // Keep same runId for all retries of the same test
251
247
  name: test.titlePath().join(" > "),
252
248
  suiteName: (project === null || project === void 0 ? void 0 : project.name) || ((_e = this.config.projects[0]) === null || _e === void 0 ? void 0 : _e.name) || "Default Suite",
@@ -274,7 +270,7 @@ class PlaywrightPulseReporter {
274
270
  if (!attachment.path)
275
271
  continue;
276
272
  try {
277
- const testSubfolder = testIdWithRetries.replace(/[^a-zA-Z0-9_-]/g, "_");
273
+ const testSubfolder = `${test.id}-${result.retry}`.replace(/[^a-zA-Z0-9_-]/g, "_");
278
274
  const safeAttachmentName = path
279
275
  .basename(attachment.path)
280
276
  .replace(/[^a-zA-Z0-9_.-]/g, "_");
@@ -307,10 +303,6 @@ class PlaywrightPulseReporter {
307
303
  this.results.push(pulseResult);
308
304
  }
309
305
  _getBaseTestId(testResultId) {
310
- const parts = testResultId.split("-");
311
- if (parts.length > 1 && !isNaN(parseInt(parts[parts.length - 1]))) {
312
- return parts.slice(0, -1).join("-");
313
- }
314
306
  return testResultId;
315
307
  }
316
308
  _getStatusOrder(status) {
@@ -328,11 +320,10 @@ class PlaywrightPulseReporter {
328
320
  }
329
321
  }
330
322
  /**
331
- * Modified: Groups all run attempts for a single logical test case and updates flaky status.
332
- * This ensures that tests with multiple retries are counted as single test case
333
- * while preserving all retry data in the JSON report.
323
+ * Groups all run attempts for a single logical test case and creates consolidated test results.
324
+ * This matches Playwright's default structure where retry attempts are grouped under one test entry.
334
325
  * @param allAttempts An array of all individual test run attempts.
335
- * @returns An array of ConsolidatedTestResult objects, where each object represents one logical test and contains an array of all its runs.
326
+ * @returns An array of ConsolidatedTestResult objects, where each object represents one logical test with all its retry attempts.
336
327
  */
337
328
  _getFinalizedResults(allAttempts) {
338
329
  const groupedResults = new Map();
@@ -347,11 +338,11 @@ class PlaywrightPulseReporter {
347
338
  for (const [baseId, runs] of groupedResults.entries()) {
348
339
  let overallStatus = "passed";
349
340
  if (runs.length > 1) {
350
- const hasPassedRun = runs.some(run => run.status === "passed");
351
- const hasFailedRun = runs.some(run => run.status === "failed");
341
+ const hasPassedRun = runs.some((run) => run.status === "passed");
342
+ const hasFailedRun = runs.some((run) => run.status === "failed");
352
343
  if (hasPassedRun && hasFailedRun) {
353
344
  overallStatus = "flaky";
354
- runs.forEach(run => {
345
+ runs.forEach((run) => {
355
346
  if (run.status === "passed" || run.status === "failed") {
356
347
  run.status = "flaky";
357
348
  }
@@ -360,7 +351,7 @@ class PlaywrightPulseReporter {
360
351
  else if (hasFailedRun) {
361
352
  overallStatus = "failed";
362
353
  }
363
- else if (runs.some(run => run.status === "skipped")) {
354
+ else if (runs.some((run) => run.status === "skipped")) {
364
355
  overallStatus = "skipped";
365
356
  }
366
357
  }
@@ -378,7 +369,7 @@ class PlaywrightPulseReporter {
378
369
  id: baseId,
379
370
  name: bestRun.name,
380
371
  suiteName: bestRun.suiteName,
381
- status: overallStatus, // Use the determined overall status
372
+ status: overallStatus,
382
373
  duration: overallDuration,
383
374
  startTime: new Date(Math.min(...startTimes)),
384
375
  endTime: new Date(Math.max(...endTimes)),
@@ -389,6 +380,38 @@ class PlaywrightPulseReporter {
389
380
  }
390
381
  return finalResults;
391
382
  }
383
+ /**
384
+ * Helper method to get summary statistics from consolidated results
385
+ */
386
+ _getSummaryStats(consolidatedResults) {
387
+ let passed = 0;
388
+ let failed = 0;
389
+ let skipped = 0;
390
+ let flaky = 0;
391
+ for (const result of consolidatedResults) {
392
+ switch (result.status) {
393
+ case "passed":
394
+ passed++;
395
+ break;
396
+ case "failed":
397
+ failed++;
398
+ break;
399
+ case "skipped":
400
+ skipped++;
401
+ break;
402
+ case "flaky":
403
+ flaky++;
404
+ break;
405
+ }
406
+ }
407
+ return {
408
+ passed,
409
+ failed,
410
+ skipped,
411
+ flaky,
412
+ totalTests: consolidatedResults.length,
413
+ };
414
+ }
392
415
  onError(error) {
393
416
  var _a;
394
417
  console.error(`PlaywrightPulseReporter: Error encountered (Shard: ${(_a = this.shardIndex) !== null && _a !== void 0 ? _a : "Main"}):`, (error === null || error === void 0 ? void 0 : error.message) || error);
@@ -441,12 +464,13 @@ class PlaywrightPulseReporter {
441
464
  }
442
465
  }
443
466
  }
444
- const finalResultsList = this._getFinalizedResults(allShardRawResults);
445
- finalRunData.passed = finalResultsList.filter((r) => r.status === "passed").length;
446
- finalRunData.failed = finalResultsList.filter((r) => r.status === "failed").length;
447
- finalRunData.skipped = finalResultsList.filter((r) => r.status === "skipped").length;
448
- finalRunData.flaky = finalResultsList.filter((r) => r.status === "flaky").length;
449
- finalRunData.totalTests = finalResultsList.length;
467
+ const consolidatedResults = this._getFinalizedResults(allShardRawResults);
468
+ const summaryStats = this._getSummaryStats(consolidatedResults);
469
+ finalRunData.passed = summaryStats.passed;
470
+ finalRunData.failed = summaryStats.failed;
471
+ finalRunData.skipped = summaryStats.skipped;
472
+ finalRunData.flaky = summaryStats.flaky;
473
+ finalRunData.totalTests = summaryStats.totalTests;
450
474
  const reviveDates = (key, value) => {
451
475
  const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
452
476
  if (typeof value === "string" && isoDateRegex.test(value)) {
@@ -455,10 +479,10 @@ class PlaywrightPulseReporter {
455
479
  }
456
480
  return value;
457
481
  };
458
- const properlyTypedResults = JSON.parse(JSON.stringify(allShardRawResults), reviveDates);
482
+ const properlyTypedResults = JSON.parse(JSON.stringify(consolidatedResults), reviveDates);
459
483
  return {
460
484
  run: finalRunData,
461
- results: properlyTypedResults, // Fixed: Include ALL retry attempts
485
+ results: properlyTypedResults, // Use consolidated results that group retry attempts
462
486
  metadata: { generatedAt: new Date().toISOString() },
463
487
  };
464
488
  }
@@ -494,7 +518,8 @@ class PlaywrightPulseReporter {
494
518
  }
495
519
  let finalReport;
496
520
  const allAttempts = this.results;
497
- const summaryResults = this._getFinalizedResults(this.results);
521
+ const consolidatedResults = this._getFinalizedResults(this.results);
522
+ const summaryStats = this._getSummaryStats(consolidatedResults);
498
523
  const runEndTime = Date.now();
499
524
  const duration = runEndTime - this.runStartTime;
500
525
  const runId = this.currentRunId;
@@ -502,26 +527,21 @@ class PlaywrightPulseReporter {
502
527
  const runData = {
503
528
  id: runId,
504
529
  timestamp: new Date(this.runStartTime),
505
- totalTests: summaryResults.length, // Count each logical test once
506
- passed: summaryResults.filter((r) => r.status === "passed").length,
507
- failed: summaryResults.filter((r) => r.status === "failed").length,
508
- skipped: summaryResults.filter((r) => r.status === "skipped").length,
509
- flaky: summaryResults.filter((r) => r.status === "flaky").length,
530
+ totalTests: summaryStats.totalTests,
531
+ passed: summaryStats.passed,
532
+ failed: summaryStats.failed,
533
+ skipped: summaryStats.skipped,
534
+ flaky: summaryStats.flaky,
510
535
  duration,
511
536
  environment: environmentDetails,
512
537
  };
513
- finalReport = {
514
- run: runData,
515
- results: allAttempts, // Include all retry attempts in the JSON
516
- metadata: { generatedAt: new Date().toISOString() },
517
- };
518
538
  if (this.isSharded) {
519
539
  finalReport = await this._mergeShardResults(runData);
520
540
  }
521
541
  else {
522
542
  finalReport = {
523
543
  run: runData,
524
- results: allAttempts, // Modified: Use all attempts instead of consolidated
544
+ results: consolidatedResults, // Use consolidated results that group retry attempts
525
545
  metadata: { generatedAt: new Date().toISOString() },
526
546
  };
527
547
  }
@@ -604,7 +624,7 @@ class PlaywrightPulseReporter {
604
624
  const json = JSON.parse(content);
605
625
  if (json.results) {
606
626
  json.results.forEach((testResult) => {
607
- // Check if the TestResult has a 'runs' array (new format)
627
+ // Check if the TestResult has a 'runs' array (consolidated format)
608
628
  if ("runs" in testResult && Array.isArray(testResult.runs)) {
609
629
  allResultsFromAllFiles.push(...testResult.runs);
610
630
  }
@@ -619,7 +639,8 @@ class PlaywrightPulseReporter {
619
639
  console.warn(`Pulse Reporter: Could not parse report file ${filePath}. Skipping. Error: ${err.message}`);
620
640
  }
621
641
  }
622
- const finalMergedResults = this._getFinalizedResults(allResultsFromAllFiles);
642
+ const consolidatedResults = this._getFinalizedResults(allResultsFromAllFiles);
643
+ const summaryStats = this._getSummaryStats(consolidatedResults);
623
644
  for (const res of allResultsFromAllFiles) {
624
645
  if (res.startTime.getTime() < earliestStartTime)
625
646
  earliestStartTime = res.startTime.getTime();
@@ -631,16 +652,16 @@ class PlaywrightPulseReporter {
631
652
  id: `merged-${Date.now()}`,
632
653
  timestamp: latestTimestamp,
633
654
  environment: lastRunEnvironment,
634
- totalTests: finalMergedResults.length, // Count each logical test once
635
- passed: finalMergedResults.filter((r) => r.status === "passed").length,
636
- failed: finalMergedResults.filter((r) => r.status === "failed").length,
637
- skipped: finalMergedResults.filter((r) => r.status === "skipped").length,
638
- flaky: finalMergedResults.filter((r) => r.status === "flaky").length,
655
+ totalTests: summaryStats.totalTests,
656
+ passed: summaryStats.passed,
657
+ failed: summaryStats.failed,
658
+ skipped: summaryStats.skipped,
659
+ flaky: summaryStats.flaky,
639
660
  duration: totalDuration,
640
661
  };
641
662
  const finalReport = {
642
663
  run: combinedRun,
643
- results: allResultsFromAllFiles, // Fixed: Include ALL retry attempts
664
+ results: consolidatedResults, // Use consolidated results that group retry attempts
644
665
  metadata: {
645
666
  generatedAt: new Date().toISOString(),
646
667
  },
@@ -652,7 +673,7 @@ class PlaywrightPulseReporter {
652
673
  return value;
653
674
  }, 2));
654
675
  if (this.printsToStdio()) {
655
- console.log(`PlaywrightPulseReporter: ✅ Merged report with ${allResultsFromAllFiles.length} total retry attempts (${finalMergedResults.length} unique tests) saved to ${finalOutputPath}`);
676
+ console.log(`PlaywrightPulseReporter: ✅ Merged report with ${allResultsFromAllFiles.length} total retry attempts (${summaryStats.totalTests} unique tests) saved to ${finalOutputPath}`);
656
677
  }
657
678
  }
658
679
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
- "version": "0.1.2-beta-7",
3
+ "version": "0.1.2-beta-9",
4
4
  "description": "A Playwright reporter and dashboard for visualizing test results.",
5
5
  "homepage": "https://playwright-pulse-report.netlify.app/",
6
6
  "keywords": [