@arghajit/dummy 0.1.2-beta-3 → 0.1.2-beta-5

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,7 +23,9 @@ export declare class PlaywrightPulseReporter implements Reporter {
23
23
  private _getBaseTestId;
24
24
  private _getStatusOrder;
25
25
  /**
26
- * Refactored to group all run attempts for a single logical test case.
26
+ * Modified: Groups all run attempts for a single logical test case.
27
+ * This ensures that tests with multiple retries are counted as single test case
28
+ * while preserving all retry data in the JSON report.
27
29
  * @param allAttempts An array of all individual test run attempts.
28
30
  * @returns An array of ConsolidatedTestResult objects, where each object represents one logical test and contains an array of all its runs.
29
31
  */
@@ -244,11 +244,10 @@ class PlaywrightPulseReporter {
244
244
  ? JSON.stringify(this.config.metadata)
245
245
  : undefined,
246
246
  };
247
- // Correctly handle the ID for each run attempt.
248
- const testIdWithRunCounter = `${test.id}-run-${result.retry}`;
247
+ const testIdWithRetries = `${test.id}-${result.retry}`;
249
248
  const pulseResult = {
250
- id: testIdWithRunCounter,
251
- runId: this.currentRunId,
249
+ id: testIdWithRetries, // Modified: Use retry number instead of "run-X"
250
+ runId: this.currentRunId, // Keep same runId for all retries of the same test
252
251
  name: test.titlePath().join(" > "),
253
252
  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",
254
253
  status: testStatus,
@@ -256,8 +255,7 @@ class PlaywrightPulseReporter {
256
255
  startTime: startTime,
257
256
  endTime: endTime,
258
257
  browser: browserDetails,
259
- retries: result.retry,
260
- runCounter: result.retry,
258
+ retries: result.retry, // This is the retry count (0 for initial run, 1+ for retries)
261
259
  steps: ((_f = result.steps) === null || _f === void 0 ? void 0 : _f.length) ? await processAllSteps(result.steps) : [],
262
260
  errorMessage: (_g = result.error) === null || _g === void 0 ? void 0 : _g.message,
263
261
  stackTrace: (_h = result.error) === null || _h === void 0 ? void 0 : _h.stack,
@@ -276,7 +274,7 @@ class PlaywrightPulseReporter {
276
274
  if (!attachment.path)
277
275
  continue;
278
276
  try {
279
- const testSubfolder = testIdWithRunCounter.replace(/[^a-zA-Z0-9_-]/g, "_");
277
+ const testSubfolder = testIdWithRetries.replace(/[^a-zA-Z0-9_-]/g, "_");
280
278
  const safeAttachmentName = path
281
279
  .basename(attachment.path)
282
280
  .replace(/[^a-zA-Z0-9_.-]/g, "_");
@@ -308,10 +306,12 @@ class PlaywrightPulseReporter {
308
306
  }
309
307
  this.results.push(pulseResult);
310
308
  }
311
- // New method to extract the base test ID, ignoring the run-counter suffix
312
309
  _getBaseTestId(testResultId) {
313
- const parts = testResultId.split("-run-");
314
- return parts[0];
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
+ return testResultId;
315
315
  }
316
316
  _getStatusOrder(status) {
317
317
  switch (status) {
@@ -328,7 +328,9 @@ class PlaywrightPulseReporter {
328
328
  }
329
329
  }
330
330
  /**
331
- * Refactored to group all run attempts for a single logical test case.
331
+ * Modified: Groups all run attempts for a single logical test case.
332
+ * This ensures that tests with multiple retries are counted as single test case
333
+ * while preserving all retry data in the JSON report.
332
334
  * @param allAttempts An array of all individual test run attempts.
333
335
  * @returns An array of ConsolidatedTestResult objects, where each object represents one logical test and contains an array of all its runs.
334
336
  */
@@ -343,9 +345,17 @@ class PlaywrightPulseReporter {
343
345
  }
344
346
  const finalResults = [];
345
347
  for (const [baseId, runs] of groupedResults.entries()) {
346
- // Sort runs to find the best status
348
+ // Sort runs to find the best status (passed > flaky > failed > skipped)
347
349
  runs.sort((a, b) => this._getStatusOrder(a.status) - this._getStatusOrder(b.status));
348
350
  const bestRun = runs[0];
351
+ let overallStatus = bestRun.status;
352
+ if (runs.length > 1) {
353
+ const hasPassedRun = runs.some((run) => run.status === "passed");
354
+ const hasFailedRun = runs.some((run) => run.status === "failed");
355
+ if (hasPassedRun && hasFailedRun) {
356
+ overallStatus = "flaky";
357
+ }
358
+ }
349
359
  // Calculate total duration from the earliest start to the latest end time of all runs
350
360
  const startTimes = runs.map((run) => run.startTime.getTime());
351
361
  const endTimes = runs.map((run) => run.endTime.getTime());
@@ -354,13 +364,13 @@ class PlaywrightPulseReporter {
354
364
  id: baseId,
355
365
  name: bestRun.name,
356
366
  suiteName: bestRun.suiteName,
357
- status: bestRun.status,
367
+ status: overallStatus, // Use the determined overall status
358
368
  duration: overallDuration,
359
369
  startTime: new Date(Math.min(...startTimes)),
360
370
  endTime: new Date(Math.max(...endTimes)),
361
371
  browser: bestRun.browser,
362
372
  tags: bestRun.tags,
363
- runs: runs.sort((a, b) => a.runCounter - b.runCounter), // Sort runs chronologically for the report
373
+ runs: runs.sort((a, b) => a.retries - b.retries), // Sort runs chronologically for the report
364
374
  });
365
375
  }
366
376
  return finalResults;
@@ -468,7 +478,9 @@ class PlaywrightPulseReporter {
468
478
  await this._writeShardResults();
469
479
  return;
470
480
  }
471
- const finalResults = this._getFinalizedResults(this.results);
481
+ let finalReport;
482
+ const allAttempts = this.results;
483
+ const summaryResults = this._getFinalizedResults(this.results);
472
484
  const runEndTime = Date.now();
473
485
  const duration = runEndTime - this.runStartTime;
474
486
  const runId = this.currentRunId;
@@ -476,22 +488,26 @@ class PlaywrightPulseReporter {
476
488
  const runData = {
477
489
  id: runId,
478
490
  timestamp: new Date(this.runStartTime),
479
- totalTests: finalResults.length,
480
- passed: finalResults.filter((r) => r.status === "passed").length,
481
- failed: finalResults.filter((r) => r.status === "failed").length,
482
- skipped: finalResults.filter((r) => r.status === "skipped").length,
483
- flaky: finalResults.filter((r) => r.status === "flaky").length,
491
+ totalTests: summaryResults.length, // Count each logical test once
492
+ passed: summaryResults.filter((r) => r.status === "passed").length,
493
+ failed: summaryResults.filter((r) => r.status === "failed").length,
494
+ skipped: summaryResults.filter((r) => r.status === "skipped").length,
495
+ flaky: summaryResults.filter((r) => r.status === "flaky").length,
484
496
  duration,
485
497
  environment: environmentDetails,
486
498
  };
487
- let finalReport = undefined;
499
+ finalReport = {
500
+ run: runData,
501
+ results: allAttempts, // Include all retry attempts in the JSON
502
+ metadata: { generatedAt: new Date().toISOString() },
503
+ };
488
504
  if (this.isSharded) {
489
505
  finalReport = await this._mergeShardResults(runData);
490
506
  }
491
507
  else {
492
508
  finalReport = {
493
509
  run: runData,
494
- results: finalResults, // Cast to any to bypass the type mismatch
510
+ results: allAttempts, // Modified: Use all attempts instead of consolidated
495
511
  metadata: { generatedAt: new Date().toISOString() },
496
512
  };
497
513
  }
@@ -572,8 +588,6 @@ class PlaywrightPulseReporter {
572
588
  try {
573
589
  const content = await fs.readFile(filePath, "utf-8");
574
590
  const json = JSON.parse(content);
575
- // This is the tricky part. We need to handle both old and new report formats.
576
- // Assuming the `results` array might contain the old, single-run objects or the new, consolidated ones.
577
591
  if (json.results) {
578
592
  json.results.forEach((testResult) => {
579
593
  // Check if the TestResult has a 'runs' array (new format)
@@ -582,7 +596,7 @@ class PlaywrightPulseReporter {
582
596
  }
583
597
  else {
584
598
  // This is the old format (single run). We'll treat it as a single attempt.
585
- allResultsFromAllFiles.push(testResult); // Cast to any to get properties
599
+ allResultsFromAllFiles.push(testResult);
586
600
  }
587
601
  });
588
602
  }
@@ -603,7 +617,7 @@ class PlaywrightPulseReporter {
603
617
  id: `merged-${Date.now()}`,
604
618
  timestamp: latestTimestamp,
605
619
  environment: lastRunEnvironment,
606
- totalTests: finalMergedResults.length,
620
+ totalTests: finalMergedResults.length, // Count each logical test once
607
621
  passed: finalMergedResults.filter((r) => r.status === "passed").length,
608
622
  failed: finalMergedResults.filter((r) => r.status === "failed").length,
609
623
  skipped: finalMergedResults.filter((r) => r.status === "skipped").length,
@@ -24,7 +24,6 @@ export interface TestResult {
24
24
  startTime: Date;
25
25
  endTime: Date;
26
26
  retries: number;
27
- runCounter: number;
28
27
  steps: TestStep[];
29
28
  errorMessage?: string;
30
29
  stackTrace?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
- "version": "0.1.2-beta-3",
3
+ "version": "0.1.2-beta-5",
4
4
  "description": "A Playwright reporter and dashboard for visualizing test results.",
5
5
  "homepage": "https://playwright-pulse-report.netlify.app/",
6
6
  "keywords": [