@arghajit/dummy 0.1.2-beta-7 → 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 and updates flaky status.
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 and updates flaky status.
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,15 +335,18 @@ 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
343
  let overallStatus = "passed";
349
344
  if (runs.length > 1) {
350
- const hasPassedRun = runs.some(run => run.status === "passed");
351
- const hasFailedRun = runs.some(run => run.status === "failed");
345
+ const hasPassedRun = runs.some((run) => run.status === "passed");
346
+ const hasFailedRun = runs.some((run) => run.status === "failed");
352
347
  if (hasPassedRun && hasFailedRun) {
353
348
  overallStatus = "flaky";
354
- runs.forEach(run => {
349
+ runs.forEach((run) => {
355
350
  if (run.status === "passed" || run.status === "failed") {
356
351
  run.status = "flaky";
357
352
  }
@@ -360,34 +355,36 @@ class PlaywrightPulseReporter {
360
355
  else if (hasFailedRun) {
361
356
  overallStatus = "failed";
362
357
  }
363
- else if (runs.some(run => run.status === "skipped")) {
358
+ else if (runs.some((run) => run.status === "skipped")) {
364
359
  overallStatus = "skipped";
365
360
  }
366
361
  }
367
362
  else {
368
363
  overallStatus = runs[0].status;
369
364
  }
370
- // Sort runs to find the best representative run for metadata
371
- runs.sort((a, b) => this._getStatusOrder(a.status) - this._getStatusOrder(b.status));
372
- const bestRun = runs[0];
373
- // Calculate total duration from the earliest start to the latest end time of all runs
374
- const startTimes = runs.map((run) => run.startTime.getTime());
375
- const endTimes = runs.map((run) => run.endTime.getTime());
376
- const overallDuration = Math.max(...endTimes) - Math.min(...startTimes);
377
- finalResults.push({
378
- id: baseId,
379
- name: bestRun.name,
380
- suiteName: bestRun.suiteName,
381
- status: overallStatus, // Use the determined overall status
382
- duration: overallDuration,
383
- startTime: new Date(Math.min(...startTimes)),
384
- endTime: new Date(Math.max(...endTimes)),
385
- browser: bestRun.browser,
386
- tags: bestRun.tags,
387
- runs: runs.sort((a, b) => a.retries - b.retries), // Sort runs chronologically for the report
388
- });
389
- }
390
- 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
+ };
391
388
  }
392
389
  onError(error) {
393
390
  var _a;
@@ -441,12 +438,12 @@ class PlaywrightPulseReporter {
441
438
  }
442
439
  }
443
440
  }
444
- const finalResultsList = this._getFinalizedResults(allShardRawResults);
445
- finalRunData.passed = finalResultsList.filter((r) => r.status === "passed").length;
446
- finalRunData.failed = finalResultsList.filter((r) => r.status === "failed").length;
447
- finalRunData.skipped = finalResultsList.filter((r) => r.status === "skipped").length;
448
- finalRunData.flaky = finalResultsList.filter((r) => r.status === "flaky").length;
449
- 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;
450
447
  const reviveDates = (key, value) => {
451
448
  const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
452
449
  if (typeof value === "string" && isoDateRegex.test(value)) {
@@ -458,7 +455,7 @@ class PlaywrightPulseReporter {
458
455
  const properlyTypedResults = JSON.parse(JSON.stringify(allShardRawResults), reviveDates);
459
456
  return {
460
457
  run: finalRunData,
461
- results: properlyTypedResults, // Fixed: Include ALL retry attempts
458
+ results: properlyTypedResults, // Include ALL retry attempts
462
459
  metadata: { generatedAt: new Date().toISOString() },
463
460
  };
464
461
  }
@@ -494,7 +491,7 @@ class PlaywrightPulseReporter {
494
491
  }
495
492
  let finalReport;
496
493
  const allAttempts = this.results;
497
- const summaryResults = this._getFinalizedResults(this.results);
494
+ const summaryStats = this._getFinalizedResults(this.results);
498
495
  const runEndTime = Date.now();
499
496
  const duration = runEndTime - this.runStartTime;
500
497
  const runId = this.currentRunId;
@@ -502,26 +499,21 @@ class PlaywrightPulseReporter {
502
499
  const runData = {
503
500
  id: runId,
504
501
  timestamp: new Date(this.runStartTime),
505
- totalTests: summaryResults.length, // Count each logical test once
506
- passed: summaryResults.filter((r) => r.status === "passed").length,
507
- failed: summaryResults.filter((r) => r.status === "failed").length,
508
- skipped: summaryResults.filter((r) => r.status === "skipped").length,
509
- 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,
510
507
  duration,
511
508
  environment: environmentDetails,
512
509
  };
513
- finalReport = {
514
- run: runData,
515
- results: allAttempts, // Include all retry attempts in the JSON
516
- metadata: { generatedAt: new Date().toISOString() },
517
- };
518
510
  if (this.isSharded) {
519
511
  finalReport = await this._mergeShardResults(runData);
520
512
  }
521
513
  else {
522
514
  finalReport = {
523
515
  run: runData,
524
- results: allAttempts, // Modified: Use all attempts instead of consolidated
516
+ results: allAttempts, // Include all retry attempts in the JSON
525
517
  metadata: { generatedAt: new Date().toISOString() },
526
518
  };
527
519
  }
@@ -619,7 +611,7 @@ class PlaywrightPulseReporter {
619
611
  console.warn(`Pulse Reporter: Could not parse report file ${filePath}. Skipping. Error: ${err.message}`);
620
612
  }
621
613
  }
622
- const finalMergedResults = this._getFinalizedResults(allResultsFromAllFiles);
614
+ const summaryStats = this._getFinalizedResults(allResultsFromAllFiles);
623
615
  for (const res of allResultsFromAllFiles) {
624
616
  if (res.startTime.getTime() < earliestStartTime)
625
617
  earliestStartTime = res.startTime.getTime();
@@ -631,16 +623,16 @@ class PlaywrightPulseReporter {
631
623
  id: `merged-${Date.now()}`,
632
624
  timestamp: latestTimestamp,
633
625
  environment: lastRunEnvironment,
634
- totalTests: finalMergedResults.length, // Count each logical test once
635
- passed: finalMergedResults.filter((r) => r.status === "passed").length,
636
- failed: finalMergedResults.filter((r) => r.status === "failed").length,
637
- skipped: finalMergedResults.filter((r) => r.status === "skipped").length,
638
- 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,
639
631
  duration: totalDuration,
640
632
  };
641
633
  const finalReport = {
642
634
  run: combinedRun,
643
- results: allResultsFromAllFiles, // Fixed: Include ALL retry attempts
635
+ results: allResultsFromAllFiles, // Include ALL retry attempts
644
636
  metadata: {
645
637
  generatedAt: new Date().toISOString(),
646
638
  },
@@ -652,7 +644,7 @@ class PlaywrightPulseReporter {
652
644
  return value;
653
645
  }, 2));
654
646
  if (this.printsToStdio()) {
655
- 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}`);
656
648
  }
657
649
  }
658
650
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
- "version": "0.1.2-beta-7",
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": [