@arghajit/dummy 0.1.2-beta-6 → 0.1.2-beta-8

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,11 +23,11 @@ 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.
26
+ * Fixed: Groups all run attempts for a single logical test case and determines flaky status.
27
27
  * This ensures that tests with multiple retries are counted as single test case
28
28
  * while preserving all retry data in the JSON report.
29
29
  * @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.
30
+ * @returns Summary statistics for the test run.
31
31
  */
32
32
  private _getFinalizedResults;
33
33
  onError(error: any): void;
@@ -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,11 @@ class PlaywrightPulseReporter {
328
320
  }
329
321
  }
330
322
  /**
331
- * Modified: Groups all run attempts for a single logical test case.
323
+ * Fixed: Groups all run attempts for a single logical test case and determines flaky status.
332
324
  * This ensures that tests with multiple retries are counted as single test case
333
325
  * while preserving all retry data in the JSON report.
334
326
  * @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.
327
+ * @returns Summary statistics for the test run.
336
328
  */
337
329
  _getFinalizedResults(allAttempts) {
338
330
  const groupedResults = new Map();
@@ -343,37 +335,56 @@ class PlaywrightPulseReporter {
343
335
  }
344
336
  groupedResults.get(baseTestId).push(attempt);
345
337
  }
346
- const finalResults = [];
338
+ let passed = 0;
339
+ let failed = 0;
340
+ let skipped = 0;
341
+ let flaky = 0;
347
342
  for (const [baseId, runs] of groupedResults.entries()) {
348
- // Sort runs to find the best status (passed > flaky > failed > skipped)
349
- runs.sort((a, b) => this._getStatusOrder(a.status) - this._getStatusOrder(b.status));
350
- const bestRun = runs[0];
351
- let overallStatus = bestRun.status;
343
+ let overallStatus = "passed";
352
344
  if (runs.length > 1) {
353
345
  const hasPassedRun = runs.some((run) => run.status === "passed");
354
346
  const hasFailedRun = runs.some((run) => run.status === "failed");
355
347
  if (hasPassedRun && hasFailedRun) {
356
348
  overallStatus = "flaky";
349
+ runs.forEach((run) => {
350
+ if (run.status === "passed" || run.status === "failed") {
351
+ run.status = "flaky";
352
+ }
353
+ });
357
354
  }
355
+ else if (hasFailedRun) {
356
+ overallStatus = "failed";
357
+ }
358
+ else if (runs.some((run) => run.status === "skipped")) {
359
+ overallStatus = "skipped";
360
+ }
361
+ }
362
+ else {
363
+ overallStatus = runs[0].status;
358
364
  }
359
- // Calculate total duration from the earliest start to the latest end time of all runs
360
- const startTimes = runs.map((run) => run.startTime.getTime());
361
- const endTimes = runs.map((run) => run.endTime.getTime());
362
- const overallDuration = Math.max(...endTimes) - Math.min(...startTimes);
363
- finalResults.push({
364
- id: baseId,
365
- name: bestRun.name,
366
- suiteName: bestRun.suiteName,
367
- status: overallStatus, // Use the determined overall status
368
- duration: overallDuration,
369
- startTime: new Date(Math.min(...startTimes)),
370
- endTime: new Date(Math.max(...endTimes)),
371
- browser: bestRun.browser,
372
- tags: bestRun.tags,
373
- runs: runs.sort((a, b) => a.retries - b.retries), // Sort runs chronologically for the report
374
- });
375
- }
376
- return finalResults;
365
+ // Count each logical test once
366
+ switch (overallStatus) {
367
+ case "passed":
368
+ passed++;
369
+ break;
370
+ case "failed":
371
+ failed++;
372
+ break;
373
+ case "skipped":
374
+ skipped++;
375
+ break;
376
+ case "flaky":
377
+ flaky++;
378
+ break;
379
+ }
380
+ }
381
+ return {
382
+ passed,
383
+ failed,
384
+ skipped,
385
+ flaky,
386
+ totalTests: groupedResults.size,
387
+ };
377
388
  }
378
389
  onError(error) {
379
390
  var _a;
@@ -427,12 +438,12 @@ class PlaywrightPulseReporter {
427
438
  }
428
439
  }
429
440
  }
430
- const finalResultsList = this._getFinalizedResults(allShardRawResults);
431
- finalRunData.passed = finalResultsList.filter((r) => r.status === "passed").length;
432
- finalRunData.failed = finalResultsList.filter((r) => r.status === "failed").length;
433
- finalRunData.skipped = finalResultsList.filter((r) => r.status === "skipped").length;
434
- finalRunData.flaky = finalResultsList.filter((r) => r.status === "flaky").length;
435
- finalRunData.totalTests = finalResultsList.length;
441
+ const summaryStats = this._getFinalizedResults(allShardRawResults);
442
+ finalRunData.passed = summaryStats.passed;
443
+ finalRunData.failed = summaryStats.failed;
444
+ finalRunData.skipped = summaryStats.skipped;
445
+ finalRunData.flaky = summaryStats.flaky;
446
+ finalRunData.totalTests = summaryStats.totalTests;
436
447
  const reviveDates = (key, value) => {
437
448
  const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
438
449
  if (typeof value === "string" && isoDateRegex.test(value)) {
@@ -444,7 +455,7 @@ class PlaywrightPulseReporter {
444
455
  const properlyTypedResults = JSON.parse(JSON.stringify(allShardRawResults), reviveDates);
445
456
  return {
446
457
  run: finalRunData,
447
- results: properlyTypedResults, // Fixed: Include ALL retry attempts
458
+ results: properlyTypedResults, // Include ALL retry attempts
448
459
  metadata: { generatedAt: new Date().toISOString() },
449
460
  };
450
461
  }
@@ -480,7 +491,7 @@ class PlaywrightPulseReporter {
480
491
  }
481
492
  let finalReport;
482
493
  const allAttempts = this.results;
483
- const summaryResults = this._getFinalizedResults(this.results);
494
+ const summaryStats = this._getFinalizedResults(this.results);
484
495
  const runEndTime = Date.now();
485
496
  const duration = runEndTime - this.runStartTime;
486
497
  const runId = this.currentRunId;
@@ -488,26 +499,21 @@ class PlaywrightPulseReporter {
488
499
  const runData = {
489
500
  id: runId,
490
501
  timestamp: new Date(this.runStartTime),
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,
502
+ totalTests: summaryStats.totalTests, // Fixed: Count each logical test once
503
+ passed: summaryStats.passed,
504
+ failed: summaryStats.failed,
505
+ skipped: summaryStats.skipped,
506
+ flaky: summaryStats.flaky,
496
507
  duration,
497
508
  environment: environmentDetails,
498
509
  };
499
- finalReport = {
500
- run: runData,
501
- results: allAttempts, // Include all retry attempts in the JSON
502
- metadata: { generatedAt: new Date().toISOString() },
503
- };
504
510
  if (this.isSharded) {
505
511
  finalReport = await this._mergeShardResults(runData);
506
512
  }
507
513
  else {
508
514
  finalReport = {
509
515
  run: runData,
510
- results: allAttempts, // Modified: Use all attempts instead of consolidated
516
+ results: allAttempts, // Include all retry attempts in the JSON
511
517
  metadata: { generatedAt: new Date().toISOString() },
512
518
  };
513
519
  }
@@ -605,7 +611,7 @@ class PlaywrightPulseReporter {
605
611
  console.warn(`Pulse Reporter: Could not parse report file ${filePath}. Skipping. Error: ${err.message}`);
606
612
  }
607
613
  }
608
- const finalMergedResults = this._getFinalizedResults(allResultsFromAllFiles);
614
+ const summaryStats = this._getFinalizedResults(allResultsFromAllFiles);
609
615
  for (const res of allResultsFromAllFiles) {
610
616
  if (res.startTime.getTime() < earliestStartTime)
611
617
  earliestStartTime = res.startTime.getTime();
@@ -617,16 +623,16 @@ class PlaywrightPulseReporter {
617
623
  id: `merged-${Date.now()}`,
618
624
  timestamp: latestTimestamp,
619
625
  environment: lastRunEnvironment,
620
- totalTests: finalMergedResults.length, // Count each logical test once
621
- passed: finalMergedResults.filter((r) => r.status === "passed").length,
622
- failed: finalMergedResults.filter((r) => r.status === "failed").length,
623
- skipped: finalMergedResults.filter((r) => r.status === "skipped").length,
624
- flaky: finalMergedResults.filter((r) => r.status === "flaky").length,
626
+ totalTests: summaryStats.totalTests, // Fixed: Count each logical test once
627
+ passed: summaryStats.passed,
628
+ failed: summaryStats.failed,
629
+ skipped: summaryStats.skipped,
630
+ flaky: summaryStats.flaky,
625
631
  duration: totalDuration,
626
632
  };
627
633
  const finalReport = {
628
634
  run: combinedRun,
629
- results: allResultsFromAllFiles, // Fixed: Include ALL retry attempts
635
+ results: allResultsFromAllFiles, // Include ALL retry attempts
630
636
  metadata: {
631
637
  generatedAt: new Date().toISOString(),
632
638
  },
@@ -638,7 +644,7 @@ class PlaywrightPulseReporter {
638
644
  return value;
639
645
  }, 2));
640
646
  if (this.printsToStdio()) {
641
- console.log(`PlaywrightPulseReporter: ✅ Merged report with ${allResultsFromAllFiles.length} total retry attempts (${finalMergedResults.length} unique tests) saved to ${finalOutputPath}`);
647
+ console.log(`PlaywrightPulseReporter: ✅ Merged report with ${allResultsFromAllFiles.length} total retry attempts (${summaryStats.totalTests} unique tests) saved to ${finalOutputPath}`);
642
648
  }
643
649
  }
644
650
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
- "version": "0.1.2-beta-6",
3
+ "version": "0.1.2-beta-8",
4
4
  "description": "A Playwright reporter and dashboard for visualizing test results.",
5
5
  "homepage": "https://playwright-pulse-report.netlify.app/",
6
6
  "keywords": [