playwright-slack-report-burak 3.0.25 → 3.0.27
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.
- package/dist/src/ResultsParser.js +61 -7
- package/package.json +1 -1
|
@@ -9,7 +9,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
11
|
const axios = require('axios');
|
|
12
|
-
const { exec } = require('child_process');
|
|
12
|
+
const { exec, execSync } = require('child_process');
|
|
13
|
+
const { promisify } = require('util');
|
|
14
|
+
const execAsync = promisify(exec);
|
|
13
15
|
let AdmZip;
|
|
14
16
|
try {
|
|
15
17
|
AdmZip = require('adm-zip');
|
|
@@ -159,7 +161,7 @@ class ResultsParser {
|
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
this.mergeReports();
|
|
164
|
+
await this.mergeReports();
|
|
163
165
|
}
|
|
164
166
|
return summary;
|
|
165
167
|
}
|
|
@@ -567,13 +569,65 @@ class ResultsParser {
|
|
|
567
569
|
}
|
|
568
570
|
}
|
|
569
571
|
}
|
|
570
|
-
mergeReports() {
|
|
572
|
+
async mergeReports() {
|
|
571
573
|
let breakMergeWaiter = false;
|
|
572
574
|
try {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
575
|
+
const summariesDir = path.join('./', 'playwright-report');
|
|
576
|
+
const blobReportsDir = path.join(summariesDir, 'blob-reports');
|
|
577
|
+
const mergedBlobsDir = path.join(summariesDir, 'mergedBlobsDir');
|
|
578
|
+
|
|
579
|
+
// Create directory for extracted blob reports
|
|
580
|
+
if (!fs.existsSync(blobReportsDir)) {
|
|
581
|
+
fs.mkdirSync(blobReportsDir, { recursive: true });
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// Create directory for merged blob reports output
|
|
585
|
+
if (!fs.existsSync(mergedBlobsDir)) {
|
|
586
|
+
fs.mkdirSync(mergedBlobsDir, { recursive: true });
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// Extract all blob zips to preserve traces
|
|
590
|
+
console.log('Extracting blob reports to preserve traces...');
|
|
591
|
+
let hasBlobReports = false;
|
|
592
|
+
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
593
|
+
const blobZipFile = path.join(summariesDir, `blob-report-node-${i}.zip`);
|
|
594
|
+
if (fs.existsSync(blobZipFile)) {
|
|
595
|
+
if (!AdmZip) {
|
|
596
|
+
console.warn('adm-zip is required for blob extraction. Falling back to HTML report merge.');
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
const zip = new AdmZip(blobZipFile);
|
|
601
|
+
const extractPath = path.join(blobReportsDir, `node-${i}`);
|
|
602
|
+
zip.extractAllTo(extractPath, true);
|
|
603
|
+
console.log(`Extracted blob report from shard ${i}`);
|
|
604
|
+
hasBlobReports = true;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// Merge blob reports instead of HTML reports to preserve traces
|
|
609
|
+
if (hasBlobReports && fs.existsSync(blobReportsDir) && fs.readdirSync(blobReportsDir).length > 0) {
|
|
610
|
+
console.log('Merging blob reports (preserves traces)...');
|
|
611
|
+
try {
|
|
612
|
+
// Merge blob reports - use relative path from summariesDir and output to mergedBlobsDir
|
|
613
|
+
// This prevents wiping the playwright-report directory
|
|
614
|
+
const blobReportsRelativePath = path.relative(summariesDir, blobReportsDir);
|
|
615
|
+
const mergedBlobsRelativePath = path.relative(summariesDir, mergedBlobsDir);
|
|
616
|
+
await execAsync(`npx playwright merge-reports --reporter html --output-dir "${mergedBlobsRelativePath}" "${blobReportsRelativePath}"`, { cwd: summariesDir });
|
|
617
|
+
console.log('Blob reports merged successfully with traces preserved.');
|
|
618
|
+
} catch (error) {
|
|
619
|
+
console.warn('Warning: Failed to merge blob reports. Falling back to HTML merge.', error.message);
|
|
620
|
+
// Fallback to HTML merge
|
|
621
|
+
execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
|
|
622
|
+
}
|
|
623
|
+
} else {
|
|
624
|
+
// Fallback to HTML merge if no blob reports found
|
|
625
|
+
console.log('No blob reports found, falling back to HTML report merge...');
|
|
626
|
+
execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// Wait until index.html exists in mergedBlobsDir
|
|
630
|
+
while (!fs.existsSync(path.join(mergedBlobsDir, 'index.html'))) {
|
|
577
631
|
console.log('Waiting 2 seconds for merged html report to be generated...');
|
|
578
632
|
const currentTime = new Date().getTime();
|
|
579
633
|
breakMergeWaiter = false;
|
package/package.json
CHANGED