@arghajit/dummy 0.1.2-beta-4 → 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
|
-
*
|
|
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
|
-
|
|
248
|
-
const testIdWithRunCounter = `${test.id}-run-${result.retry}`;
|
|
247
|
+
const testIdWithRetries = `${test.id}-${result.retry}`;
|
|
249
248
|
const pulseResult = {
|
|
250
|
-
id:
|
|
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 =
|
|
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("-
|
|
314
|
-
|
|
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
|
-
*
|
|
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:
|
|
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.
|
|
373
|
+
runs: runs.sort((a, b) => a.retries - b.retries), // Sort runs chronologically for the report
|
|
364
374
|
});
|
|
365
375
|
}
|
|
366
376
|
return finalResults;
|
|
@@ -469,9 +479,7 @@ class PlaywrightPulseReporter {
|
|
|
469
479
|
return;
|
|
470
480
|
}
|
|
471
481
|
let finalReport;
|
|
472
|
-
// `this.results` contains all individual run attempts. We will keep them all.
|
|
473
482
|
const allAttempts = this.results;
|
|
474
|
-
// Use your existing logic ONLY to get the final statuses for the summary counts.
|
|
475
483
|
const summaryResults = this._getFinalizedResults(this.results);
|
|
476
484
|
const runEndTime = Date.now();
|
|
477
485
|
const duration = runEndTime - this.runStartTime;
|
|
@@ -480,7 +488,7 @@ class PlaywrightPulseReporter {
|
|
|
480
488
|
const runData = {
|
|
481
489
|
id: runId,
|
|
482
490
|
timestamp: new Date(this.runStartTime),
|
|
483
|
-
totalTests: summaryResults.length,
|
|
491
|
+
totalTests: summaryResults.length, // Count each logical test once
|
|
484
492
|
passed: summaryResults.filter((r) => r.status === "passed").length,
|
|
485
493
|
failed: summaryResults.filter((r) => r.status === "failed").length,
|
|
486
494
|
skipped: summaryResults.filter((r) => r.status === "skipped").length,
|
|
@@ -488,10 +496,9 @@ class PlaywrightPulseReporter {
|
|
|
488
496
|
duration,
|
|
489
497
|
environment: environmentDetails,
|
|
490
498
|
};
|
|
491
|
-
// In the final report object, use the complete list of attempts.
|
|
492
499
|
finalReport = {
|
|
493
500
|
run: runData,
|
|
494
|
-
results: allAttempts, //
|
|
501
|
+
results: allAttempts, // Include all retry attempts in the JSON
|
|
495
502
|
metadata: { generatedAt: new Date().toISOString() },
|
|
496
503
|
};
|
|
497
504
|
if (this.isSharded) {
|
|
@@ -500,7 +507,7 @@ class PlaywrightPulseReporter {
|
|
|
500
507
|
else {
|
|
501
508
|
finalReport = {
|
|
502
509
|
run: runData,
|
|
503
|
-
results:
|
|
510
|
+
results: allAttempts, // Modified: Use all attempts instead of consolidated
|
|
504
511
|
metadata: { generatedAt: new Date().toISOString() },
|
|
505
512
|
};
|
|
506
513
|
}
|
|
@@ -581,8 +588,6 @@ class PlaywrightPulseReporter {
|
|
|
581
588
|
try {
|
|
582
589
|
const content = await fs.readFile(filePath, "utf-8");
|
|
583
590
|
const json = JSON.parse(content);
|
|
584
|
-
// This is the tricky part. We need to handle both old and new report formats.
|
|
585
|
-
// Assuming the `results` array might contain the old, single-run objects or the new, consolidated ones.
|
|
586
591
|
if (json.results) {
|
|
587
592
|
json.results.forEach((testResult) => {
|
|
588
593
|
// Check if the TestResult has a 'runs' array (new format)
|
|
@@ -591,7 +596,7 @@ class PlaywrightPulseReporter {
|
|
|
591
596
|
}
|
|
592
597
|
else {
|
|
593
598
|
// This is the old format (single run). We'll treat it as a single attempt.
|
|
594
|
-
allResultsFromAllFiles.push(testResult);
|
|
599
|
+
allResultsFromAllFiles.push(testResult);
|
|
595
600
|
}
|
|
596
601
|
});
|
|
597
602
|
}
|
|
@@ -612,7 +617,7 @@ class PlaywrightPulseReporter {
|
|
|
612
617
|
id: `merged-${Date.now()}`,
|
|
613
618
|
timestamp: latestTimestamp,
|
|
614
619
|
environment: lastRunEnvironment,
|
|
615
|
-
totalTests: finalMergedResults.length,
|
|
620
|
+
totalTests: finalMergedResults.length, // Count each logical test once
|
|
616
621
|
passed: finalMergedResults.filter((r) => r.status === "passed").length,
|
|
617
622
|
failed: finalMergedResults.filter((r) => r.status === "failed").length,
|
|
618
623
|
skipped: finalMergedResults.filter((r) => r.status === "skipped").length,
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED