@arghajit/dummy 0.1.0-beta-23 → 0.1.0-beta-24

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.
@@ -19,6 +19,7 @@ export declare class PlaywrightPulseReporter implements Reporter {
19
19
  private getBrowserDetails;
20
20
  private processStep;
21
21
  onTestEnd(test: TestCase, result: PwTestResult): Promise<void>;
22
+ private _getFinalizedResults;
22
23
  onError(error: any): void;
23
24
  private _getEnvDetails;
24
25
  private _writeShardResults;
@@ -296,15 +296,18 @@ class PlaywrightPulseReporter {
296
296
  console.error(`Pulse Reporter: Failed to process attachment "${attachment.name}" for test ${pulseResult.name}. Error: ${err.message}`);
297
297
  }
298
298
  }
299
- const existingTestIndex = this.results.findIndex((r) => r.id === test.id);
300
- if (existingTestIndex !== -1) {
301
- if (pulseResult.retries >= this.results[existingTestIndex].retries) {
302
- this.results[existingTestIndex] = pulseResult;
299
+ this.results.push(pulseResult);
300
+ }
301
+ _getFinalizedResults(allResults) {
302
+ const finalResultsMap = new Map();
303
+ for (const result of allResults) {
304
+ const existing = finalResultsMap.get(result.id);
305
+ // Keep the result with the highest retry attempt for each test ID
306
+ if (!existing || result.retries >= existing.retries) {
307
+ finalResultsMap.set(result.id, result);
303
308
  }
304
309
  }
305
- else {
306
- this.results.push(pulseResult);
307
- }
310
+ return Array.from(finalResultsMap.values());
308
311
  }
309
312
  onError(error) {
310
313
  var _a;
@@ -359,14 +362,7 @@ class PlaywrightPulseReporter {
359
362
  }
360
363
  }
361
364
  }
362
- let finalUniqueResultsMap = new Map();
363
- for (const result of allShardProcessedResults) {
364
- const existing = finalUniqueResultsMap.get(result.id);
365
- if (!existing || result.retries >= existing.retries) {
366
- finalUniqueResultsMap.set(result.id, result);
367
- }
368
- }
369
- const finalResultsList = Array.from(finalUniqueResultsMap.values());
365
+ const finalResultsList = this._getFinalizedResults(allShardProcessedResults);
370
366
  finalResultsList.forEach((r) => (r.runId = finalRunData.id));
371
367
  finalRunData.passed = finalResultsList.filter((r) => r.status === "passed").length;
372
368
  finalRunData.failed = finalResultsList.filter((r) => r.status === "failed").length;
@@ -417,6 +413,8 @@ class PlaywrightPulseReporter {
417
413
  await this._writeShardResults();
418
414
  return;
419
415
  }
416
+ // De-duplicate and handle retries here, in a safe, single-threaded context.
417
+ const finalResults = this._getFinalizedResults(this.results);
420
418
  const runEndTime = Date.now();
421
419
  const duration = runEndTime - this.runStartTime;
422
420
  const runId = `run-${this.runStartTime}-581d5ad8-ce75-4ca5-94a6-ed29c466c815`;
@@ -424,26 +422,25 @@ class PlaywrightPulseReporter {
424
422
  const runData = {
425
423
  id: runId,
426
424
  timestamp: new Date(this.runStartTime),
427
- totalTests: 0,
428
- passed: 0,
429
- failed: 0,
430
- skipped: 0,
425
+ // Use the length of the de-duplicated array for all counts
426
+ totalTests: finalResults.length,
427
+ passed: finalResults.filter((r) => r.status === "passed").length,
428
+ failed: finalResults.filter((r) => r.status === "failed").length,
429
+ skipped: finalResults.filter((r) => r.status === "skipped").length,
431
430
  duration,
432
431
  environment: environmentDetails,
433
432
  };
433
+ finalResults.forEach((r) => (r.runId = runId));
434
434
  let finalReport = undefined;
435
435
  if (this.isSharded) {
436
+ // The _mergeShardResults method will handle its own de-duplication
436
437
  finalReport = await this._mergeShardResults(runData);
437
438
  }
438
439
  else {
439
- this.results.forEach((r) => (r.runId = runId));
440
- runData.passed = this.results.filter((r) => r.status === "passed").length;
441
- runData.failed = this.results.filter((r) => r.status === "failed").length;
442
- runData.skipped = this.results.filter((r) => r.status === "skipped").length;
443
- runData.totalTests = this.results.length;
444
440
  finalReport = {
445
441
  run: runData,
446
- results: this.results,
442
+ // Use the de-duplicated results
443
+ results: finalResults,
447
444
  metadata: { generatedAt: new Date().toISOString() },
448
445
  };
449
446
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
3
  "author": "Arghajit Singha",
4
- "version": "0.1.0-beta-23",
4
+ "version": "0.1.0-beta-24",
5
5
  "description": "A Playwright reporter and dashboard for visualizing test results.",
6
6
  "homepage": "https://playwright-pulse-report.netlify.app/",
7
7
  "keywords": [