@arghajit/dummy 0.1.0-beta-23 → 0.1.0-beta-25
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
442
|
+
// Use the de-duplicated results
|
|
443
|
+
results: finalResults,
|
|
447
444
|
metadata: { generatedAt: new Date().toISOString() },
|
|
448
445
|
};
|
|
449
446
|
}
|
|
@@ -515,47 +512,48 @@ class PlaywrightPulseReporter {
|
|
|
515
512
|
}
|
|
516
513
|
return;
|
|
517
514
|
}
|
|
518
|
-
const
|
|
519
|
-
id: `merged-${Date.now()}`,
|
|
520
|
-
timestamp: new Date(0),
|
|
521
|
-
totalTests: 0,
|
|
522
|
-
passed: 0,
|
|
523
|
-
failed: 0,
|
|
524
|
-
skipped: 0,
|
|
525
|
-
duration: 0,
|
|
526
|
-
environment: undefined,
|
|
527
|
-
};
|
|
528
|
-
const allResults = [];
|
|
515
|
+
const allResultsFromAllFiles = [];
|
|
529
516
|
let latestTimestamp = new Date(0);
|
|
517
|
+
let lastRunEnvironment = undefined;
|
|
518
|
+
let totalDuration = 0;
|
|
530
519
|
for (const file of reportFiles) {
|
|
531
520
|
const filePath = path.join(pulseResultsDir, file);
|
|
532
521
|
try {
|
|
533
522
|
const content = await fs.readFile(filePath, "utf-8");
|
|
534
523
|
const json = JSON.parse(content);
|
|
535
524
|
if (json.run) {
|
|
536
|
-
combinedRun.totalTests += json.run.totalTests || 0;
|
|
537
|
-
combinedRun.passed += json.run.passed || 0;
|
|
538
|
-
combinedRun.failed += json.run.failed || 0;
|
|
539
|
-
combinedRun.skipped += json.run.skipped || 0;
|
|
540
|
-
combinedRun.duration += json.run.duration || 0;
|
|
541
525
|
const runTimestamp = new Date(json.run.timestamp);
|
|
542
526
|
if (runTimestamp > latestTimestamp) {
|
|
543
527
|
latestTimestamp = runTimestamp;
|
|
544
|
-
|
|
528
|
+
lastRunEnvironment = json.run.environment || undefined;
|
|
545
529
|
}
|
|
546
530
|
}
|
|
547
531
|
if (json.results) {
|
|
548
|
-
|
|
532
|
+
allResultsFromAllFiles.push(...json.results);
|
|
549
533
|
}
|
|
550
534
|
}
|
|
551
535
|
catch (err) {
|
|
552
536
|
console.warn(`Pulse Reporter: Could not parse report file ${filePath}. Skipping. Error: ${err.message}`);
|
|
553
537
|
}
|
|
554
538
|
}
|
|
555
|
-
|
|
539
|
+
// De-duplicate the results from ALL merged files using the helper function
|
|
540
|
+
const finalMergedResults = this._getFinalizedResults(allResultsFromAllFiles);
|
|
541
|
+
// Sum the duration from the final, de-duplicated list of tests
|
|
542
|
+
totalDuration = finalMergedResults.reduce((acc, r) => acc + (r.duration || 0), 0);
|
|
543
|
+
const combinedRun = {
|
|
544
|
+
id: `merged-${Date.now()}`,
|
|
545
|
+
timestamp: latestTimestamp,
|
|
546
|
+
environment: lastRunEnvironment,
|
|
547
|
+
// Recalculate counts based on the truly final, de-duplicated list
|
|
548
|
+
totalTests: finalMergedResults.length,
|
|
549
|
+
passed: finalMergedResults.filter((r) => r.status === "passed").length,
|
|
550
|
+
failed: finalMergedResults.filter((r) => r.status === "failed").length,
|
|
551
|
+
skipped: finalMergedResults.filter((r) => r.status === "skipped").length,
|
|
552
|
+
duration: totalDuration,
|
|
553
|
+
};
|
|
556
554
|
const finalReport = {
|
|
557
555
|
run: combinedRun,
|
|
558
|
-
results:
|
|
556
|
+
results: finalMergedResults, // Use the de-duplicated list
|
|
559
557
|
metadata: {
|
|
560
558
|
generatedAt: new Date().toISOString(),
|
|
561
559
|
},
|
|
@@ -567,7 +565,7 @@ class PlaywrightPulseReporter {
|
|
|
567
565
|
return value;
|
|
568
566
|
}, 2));
|
|
569
567
|
if (this.printsToStdio()) {
|
|
570
|
-
console.log(`PlaywrightPulseReporter: ✅ Merged report with ${
|
|
568
|
+
console.log(`PlaywrightPulseReporter: ✅ Merged report with ${finalMergedResults.length} total results saved to ${finalOutputPath}`);
|
|
571
569
|
}
|
|
572
570
|
}
|
|
573
571
|
catch (err) {
|
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-
|
|
4
|
+
"version": "0.1.0-beta-25",
|
|
5
5
|
"description": "A Playwright reporter and dashboard for visualizing test results.",
|
|
6
6
|
"homepage": "https://playwright-pulse-report.netlify.app/",
|
|
7
7
|
"keywords": [
|