@arghajit/dummy 0.1.2-beta-10 → 0.1.2-beta-11
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.
|
@@ -114,6 +114,7 @@ export declare class PlaywrightPulseReporter implements Reporter {
|
|
|
114
114
|
onTestEnd(test: TestCase, result: PwTestResult): Promise<void>;
|
|
115
115
|
private _getFinalizedResults;
|
|
116
116
|
private _getSummaryStats;
|
|
117
|
+
private _getSummaryStatsFromAttempts;
|
|
117
118
|
onError(error: Error): void;
|
|
118
119
|
private _getEnvDetails;
|
|
119
120
|
private _writeShardResults;
|
|
@@ -304,6 +304,49 @@ class PlaywrightPulseReporter {
|
|
|
304
304
|
totalTests: consolidatedResults.length,
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
|
+
_getSummaryStatsFromAttempts(attempts) {
|
|
308
|
+
let passed = 0;
|
|
309
|
+
let failed = 0;
|
|
310
|
+
let skipped = 0;
|
|
311
|
+
let flaky = 0;
|
|
312
|
+
const groupedByTest = new Map();
|
|
313
|
+
for (const attempt of attempts) {
|
|
314
|
+
const baseId = attempt.id.replace(/-\d+$/, "");
|
|
315
|
+
if (!groupedByTest.has(baseId)) {
|
|
316
|
+
groupedByTest.set(baseId, []);
|
|
317
|
+
}
|
|
318
|
+
groupedByTest.get(baseId).push(attempt);
|
|
319
|
+
}
|
|
320
|
+
for (const attempt of attempts) {
|
|
321
|
+
const baseId = attempt.id.replace(/-\d+$/, "");
|
|
322
|
+
const testAttempts = groupedByTest.get(baseId);
|
|
323
|
+
const hasFailures = testAttempts.some((a) => a.status === "failed");
|
|
324
|
+
const hasPasses = testAttempts.some((a) => a.status === "passed");
|
|
325
|
+
if (hasFailures && hasPasses) {
|
|
326
|
+
flaky++;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
switch (attempt.status) {
|
|
330
|
+
case "passed":
|
|
331
|
+
passed++;
|
|
332
|
+
break;
|
|
333
|
+
case "failed":
|
|
334
|
+
failed++;
|
|
335
|
+
break;
|
|
336
|
+
case "skipped":
|
|
337
|
+
skipped++;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
passed,
|
|
344
|
+
failed,
|
|
345
|
+
skipped,
|
|
346
|
+
flaky,
|
|
347
|
+
totalTests: attempts.length,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
307
350
|
onError(error) {
|
|
308
351
|
console.error("Pulse Reporter: Error occurred:", error);
|
|
309
352
|
}
|
|
@@ -315,15 +358,11 @@ class PlaywrightPulseReporter {
|
|
|
315
358
|
cpu: os.arch(),
|
|
316
359
|
};
|
|
317
360
|
}
|
|
318
|
-
async _writeShardResults(
|
|
361
|
+
async _writeShardResults(individualResults) {
|
|
319
362
|
const tempFilePath = path.join(this.outputDir, `shard-${this.shardIndex || 0}-results.json`);
|
|
320
363
|
try {
|
|
321
364
|
await this._ensureDirExists(path.dirname(tempFilePath));
|
|
322
|
-
|
|
323
|
-
for (const result of consolidatedResults) {
|
|
324
|
-
allAttempts.push(...result.results);
|
|
325
|
-
}
|
|
326
|
-
await fs.promises.writeFile(tempFilePath, JSON.stringify(allAttempts, null, 2));
|
|
365
|
+
await fs.promises.writeFile(tempFilePath, JSON.stringify(individualResults, null, 2));
|
|
327
366
|
}
|
|
328
367
|
catch (error) {
|
|
329
368
|
console.error("Pulse Reporter: Error writing shard results:", error);
|
|
@@ -332,7 +371,6 @@ class PlaywrightPulseReporter {
|
|
|
332
371
|
async _mergeShardResults(allShardResults) {
|
|
333
372
|
try {
|
|
334
373
|
const allAttempts = allShardResults.flat();
|
|
335
|
-
const consolidatedResults = this._getFinalizedResults(allAttempts);
|
|
336
374
|
const reviveDates = (key, value) => {
|
|
337
375
|
if (typeof value === "string" &&
|
|
338
376
|
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value)) {
|
|
@@ -340,7 +378,7 @@ class PlaywrightPulseReporter {
|
|
|
340
378
|
}
|
|
341
379
|
return value;
|
|
342
380
|
};
|
|
343
|
-
const properlyTypedResults = JSON.parse(JSON.stringify(
|
|
381
|
+
const properlyTypedResults = JSON.parse(JSON.stringify(allAttempts), reviveDates);
|
|
344
382
|
return properlyTypedResults;
|
|
345
383
|
}
|
|
346
384
|
catch (error) {
|
|
@@ -370,8 +408,8 @@ class PlaywrightPulseReporter {
|
|
|
370
408
|
}
|
|
371
409
|
async onEnd(result) {
|
|
372
410
|
try {
|
|
373
|
-
const
|
|
374
|
-
const stats = this.
|
|
411
|
+
const individualResults = this.testResults;
|
|
412
|
+
const stats = this._getSummaryStatsFromAttempts(individualResults);
|
|
375
413
|
const runData = {
|
|
376
414
|
id: this.currentRunId,
|
|
377
415
|
startTime: new Date(),
|
|
@@ -382,7 +420,7 @@ class PlaywrightPulseReporter {
|
|
|
382
420
|
};
|
|
383
421
|
const finalReport = {
|
|
384
422
|
run: runData,
|
|
385
|
-
results:
|
|
423
|
+
results: individualResults,
|
|
386
424
|
summary: stats,
|
|
387
425
|
};
|
|
388
426
|
const jsonReplacer = (key, value) => {
|
|
@@ -392,7 +430,7 @@ class PlaywrightPulseReporter {
|
|
|
392
430
|
return value;
|
|
393
431
|
};
|
|
394
432
|
if (this.shardIndex !== undefined) {
|
|
395
|
-
await this._writeShardResults(
|
|
433
|
+
await this._writeShardResults(individualResults);
|
|
396
434
|
console.log(`Pulse Reporter: Shard ${this.shardIndex} results written.`);
|
|
397
435
|
}
|
|
398
436
|
else {
|
|
@@ -428,19 +466,13 @@ class PlaywrightPulseReporter {
|
|
|
428
466
|
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
429
467
|
const report = JSON.parse(content);
|
|
430
468
|
if (report.results) {
|
|
431
|
-
|
|
432
|
-
if (consolidatedResult.results &&
|
|
433
|
-
consolidatedResult.results.length > 0) {
|
|
434
|
-
allAttempts.push(...consolidatedResult.results);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
469
|
+
allAttempts.push(...report.results);
|
|
437
470
|
}
|
|
438
471
|
if ((_a = report.run) === null || _a === void 0 ? void 0 : _a.duration) {
|
|
439
472
|
totalDuration += report.run.duration;
|
|
440
473
|
}
|
|
441
474
|
}
|
|
442
|
-
const
|
|
443
|
-
const stats = this._getSummaryStats(consolidatedResults);
|
|
475
|
+
const stats = this._getSummaryStatsFromAttempts(allAttempts);
|
|
444
476
|
const combinedRun = {
|
|
445
477
|
id: this.currentRunId,
|
|
446
478
|
startTime: new Date(),
|
|
@@ -451,7 +483,7 @@ class PlaywrightPulseReporter {
|
|
|
451
483
|
};
|
|
452
484
|
const finalReport = {
|
|
453
485
|
run: combinedRun,
|
|
454
|
-
results:
|
|
486
|
+
results: allAttempts,
|
|
455
487
|
summary: stats,
|
|
456
488
|
};
|
|
457
489
|
return finalReport;
|
package/package.json
CHANGED