playwright-slack-report-burak 3.0.28 ā 3.0.30
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 +159 -15
- package/package.json +1 -1
|
@@ -48,6 +48,66 @@ class ResultsParser {
|
|
|
48
48
|
// Log package version
|
|
49
49
|
console.log(`š¦ [ResultsParser] playwright-slack-report-burak v${packageVersion}`);
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Recursively print directory tree structure
|
|
53
|
+
* @param {string} dirPath - Directory path to print
|
|
54
|
+
* @param {string} prefix - Prefix for tree visualization
|
|
55
|
+
* @param {number} maxDepth - Maximum depth to traverse (default: 5)
|
|
56
|
+
*/
|
|
57
|
+
printDirectoryTree(dirPath, prefix = '', maxDepth = 5) {
|
|
58
|
+
if (maxDepth <= 0) return;
|
|
59
|
+
if (!fs.existsSync(dirPath)) {
|
|
60
|
+
console.log(`${prefix}${path.basename(dirPath)}/ (does not exist)`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const stats = fs.statSync(dirPath);
|
|
66
|
+
if (!stats.isDirectory()) {
|
|
67
|
+
const size = stats.size;
|
|
68
|
+
const sizeStr = size > 1024 ? `${(size / 1024).toFixed(2)}KB` : `${size}B`;
|
|
69
|
+
console.log(`${prefix}${path.basename(dirPath)} (${sizeStr})`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const dirName = path.basename(dirPath) || dirPath;
|
|
74
|
+
console.log(`${prefix}${dirName}/`);
|
|
75
|
+
|
|
76
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
77
|
+
entries.sort((a, b) => {
|
|
78
|
+
if (a.isDirectory() && !b.isDirectory()) return -1;
|
|
79
|
+
if (!a.isDirectory() && b.isDirectory()) return 1;
|
|
80
|
+
return a.name.localeCompare(b.name);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
entries.forEach((entry, index) => {
|
|
84
|
+
const isLast = index === entries.length - 1;
|
|
85
|
+
const newPrefix = prefix + (isLast ? 'āāā ' : 'āāā ');
|
|
86
|
+
const nextPrefix = prefix + (isLast ? ' ' : 'ā ');
|
|
87
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
88
|
+
|
|
89
|
+
if (entry.isDirectory()) {
|
|
90
|
+
this.printDirectoryTree(fullPath, nextPrefix, maxDepth - 1);
|
|
91
|
+
} else {
|
|
92
|
+
try {
|
|
93
|
+
const fileStats = fs.statSync(fullPath);
|
|
94
|
+
const size = fileStats.size;
|
|
95
|
+
const sizeStr = size > 1024 * 1024
|
|
96
|
+
? `${(size / (1024 * 1024)).toFixed(2)}MB`
|
|
97
|
+
: size > 1024
|
|
98
|
+
? `${(size / 1024).toFixed(2)}KB`
|
|
99
|
+
: `${size}B`;
|
|
100
|
+
console.log(`${newPrefix}${entry.name} (${sizeStr})`);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.log(`${newPrefix}${entry.name} (error reading)`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.log(`${prefix}${path.basename(dirPath)}/ (error: ${error.message})`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
51
111
|
/**
|
|
52
112
|
* Update shard information after detection (e.g., from GitHub API)
|
|
53
113
|
* @param {number} shardIndex - The current shard index (1-based, shard 1 is aggregator)
|
|
@@ -570,12 +630,24 @@ class ResultsParser {
|
|
|
570
630
|
}
|
|
571
631
|
}
|
|
572
632
|
async mergeReports() {
|
|
573
|
-
let breakMergeWaiter = false;
|
|
574
633
|
try {
|
|
575
634
|
const summariesDir = path.join('./', 'playwright-report');
|
|
576
635
|
const blobReportsDir = path.join(summariesDir, 'blob-reports');
|
|
577
636
|
const mergedBlobsDir = path.join(summariesDir, 'mergedBlobsDir');
|
|
578
637
|
|
|
638
|
+
console.log('\n=== Starting merge process ===');
|
|
639
|
+
console.log(`Summaries directory: ${path.resolve(summariesDir)}`);
|
|
640
|
+
console.log(`Blob reports directory: ${path.resolve(blobReportsDir)}`);
|
|
641
|
+
console.log(`Merged blobs directory: ${path.resolve(mergedBlobsDir)}`);
|
|
642
|
+
|
|
643
|
+
// Show initial directory structure
|
|
644
|
+
console.log('\nš Initial playwright-report directory structure:');
|
|
645
|
+
if (fs.existsSync(summariesDir)) {
|
|
646
|
+
this.printDirectoryTree(summariesDir);
|
|
647
|
+
} else {
|
|
648
|
+
console.log(' (directory does not exist yet)');
|
|
649
|
+
}
|
|
650
|
+
|
|
579
651
|
// Create directory for extracted blob reports
|
|
580
652
|
if (!fs.existsSync(blobReportsDir)) {
|
|
581
653
|
fs.mkdirSync(blobReportsDir, { recursive: true });
|
|
@@ -587,7 +659,7 @@ class ResultsParser {
|
|
|
587
659
|
}
|
|
588
660
|
|
|
589
661
|
// Extract all blob zips to preserve traces
|
|
590
|
-
console.log('Extracting blob reports to preserve traces...');
|
|
662
|
+
console.log('\nš¦ Extracting blob reports to preserve traces...');
|
|
591
663
|
let hasBlobReports = false;
|
|
592
664
|
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
593
665
|
const blobZipFile = path.join(summariesDir, `blob-report-node-${i}.zip`);
|
|
@@ -605,20 +677,70 @@ class ResultsParser {
|
|
|
605
677
|
}
|
|
606
678
|
}
|
|
607
679
|
|
|
680
|
+
// Show directory structure after extraction
|
|
681
|
+
if (hasBlobReports) {
|
|
682
|
+
console.log('\nš Directory structure after blob extraction:');
|
|
683
|
+
this.printDirectoryTree(summariesDir);
|
|
684
|
+
}
|
|
685
|
+
|
|
608
686
|
// Merge blob reports instead of HTML reports to preserve traces
|
|
609
687
|
if (hasBlobReports && fs.existsSync(blobReportsDir) && fs.readdirSync(blobReportsDir).length > 0) {
|
|
610
|
-
console.log('Merging blob reports (preserves traces)...');
|
|
688
|
+
console.log('\nš Merging blob reports (preserves traces)...');
|
|
689
|
+
let tempConfigPath = null;
|
|
611
690
|
try {
|
|
612
|
-
// Merge blob reports - use
|
|
691
|
+
// Merge blob reports - use config file to specify output directory
|
|
613
692
|
// This prevents wiping the playwright-report directory
|
|
614
693
|
const blobReportsRelativePath = path.relative(summariesDir, blobReportsDir);
|
|
615
|
-
const
|
|
616
|
-
|
|
694
|
+
const mergedBlobsAbsolutePath = path.resolve(mergedBlobsDir);
|
|
695
|
+
console.log(`Merging blob reports from: ${blobReportsRelativePath}`);
|
|
696
|
+
console.log(`Output directory: ${mergedBlobsAbsolutePath}`);
|
|
697
|
+
|
|
698
|
+
// Create temporary config file to specify output folder
|
|
699
|
+
tempConfigPath = path.join(summariesDir, 'merge-config.js');
|
|
700
|
+
// Escape backslashes and single quotes in path for JavaScript string
|
|
701
|
+
const escapedPath = mergedBlobsAbsolutePath.replace(/\\/g, '/').replace(/'/g, "\\'");
|
|
702
|
+
const configContent = `module.exports = {
|
|
703
|
+
reporter: [['html', { outputFolder: '${escapedPath}' }]]
|
|
704
|
+
};`;
|
|
705
|
+
fs.writeFileSync(tempConfigPath, configContent);
|
|
706
|
+
console.log(`Created temporary config file: ${tempConfigPath}`);
|
|
707
|
+
console.log(`Config content: ${configContent}`);
|
|
708
|
+
|
|
709
|
+
const mergeCommand = `npx playwright merge-reports --reporter html --config "${tempConfigPath}" "${blobReportsRelativePath}"`;
|
|
710
|
+
console.log(`Executing: ${mergeCommand}`);
|
|
711
|
+
const mergeResult = await execAsync(mergeCommand, { cwd: summariesDir });
|
|
712
|
+
console.log('Merge command output:', mergeResult.stdout);
|
|
713
|
+
if (mergeResult.stderr) {
|
|
714
|
+
console.warn('Merge command stderr:', mergeResult.stderr);
|
|
715
|
+
}
|
|
617
716
|
console.log('Blob reports merged successfully with traces preserved.');
|
|
717
|
+
|
|
718
|
+
// Show directory structure after merge
|
|
719
|
+
console.log('\nš Directory structure after merge:');
|
|
720
|
+
this.printDirectoryTree(summariesDir);
|
|
721
|
+
console.log('\nš Merged blobs directory contents:');
|
|
722
|
+
this.printDirectoryTree(mergedBlobsDir);
|
|
618
723
|
} catch (error) {
|
|
619
724
|
console.warn('Warning: Failed to merge blob reports. Falling back to HTML merge.', error.message);
|
|
725
|
+
if (error.stdout) console.log('Merge stdout:', error.stdout);
|
|
726
|
+
if (error.stderr) console.warn('Merge stderr:', error.stderr);
|
|
727
|
+
|
|
728
|
+
// Show directory structure after failed merge
|
|
729
|
+
console.log('\nš Directory structure after failed merge:');
|
|
730
|
+
this.printDirectoryTree(summariesDir);
|
|
731
|
+
|
|
620
732
|
// Fallback to HTML merge
|
|
621
733
|
execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
|
|
734
|
+
} finally {
|
|
735
|
+
// Clean up temporary config file
|
|
736
|
+
if (tempConfigPath && fs.existsSync(tempConfigPath)) {
|
|
737
|
+
try {
|
|
738
|
+
fs.unlinkSync(tempConfigPath);
|
|
739
|
+
console.log(`Cleaned up temporary config file: ${tempConfigPath}`);
|
|
740
|
+
} catch (cleanupError) {
|
|
741
|
+
console.warn(`Warning: Failed to clean up temp config file: ${cleanupError.message}`);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
622
744
|
}
|
|
623
745
|
} else {
|
|
624
746
|
// Fallback to HTML merge if no blob reports found
|
|
@@ -626,18 +748,40 @@ class ResultsParser {
|
|
|
626
748
|
execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
|
|
627
749
|
}
|
|
628
750
|
|
|
629
|
-
// Wait until index.html exists in mergedBlobsDir
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
751
|
+
// Wait until index.html exists in mergedBlobsDir (with timeout)
|
|
752
|
+
const maxWaitTime = 60000; // 60 seconds max wait
|
|
753
|
+
const startWaitTime = new Date().getTime();
|
|
754
|
+
const indexHtmlPath = path.join(mergedBlobsDir, 'index.html');
|
|
755
|
+
|
|
756
|
+
console.log('\nā³ Waiting for merged HTML report to be generated...');
|
|
757
|
+
while (!fs.existsSync(indexHtmlPath)) {
|
|
758
|
+
const elapsed = new Date().getTime() - startWaitTime;
|
|
759
|
+
if (elapsed > maxWaitTime) {
|
|
760
|
+
console.warn(`\nā±ļø Timeout: index.html not found in ${mergedBlobsDir} after ${maxWaitTime}ms`);
|
|
761
|
+
console.log(`Checking if directory exists: ${fs.existsSync(mergedBlobsDir)}`);
|
|
762
|
+
if (fs.existsSync(mergedBlobsDir)) {
|
|
763
|
+
console.log('\nš Full directory tree at timeout:');
|
|
764
|
+
this.printDirectoryTree(summariesDir);
|
|
765
|
+
console.log('\nš Merged blobs directory detailed contents:');
|
|
766
|
+
this.printDirectoryTree(mergedBlobsDir);
|
|
767
|
+
} else {
|
|
768
|
+
console.log('Merged blobs directory does not exist!');
|
|
637
769
|
}
|
|
770
|
+
break;
|
|
638
771
|
}
|
|
772
|
+
console.log(`Waiting for merged html report to be generated... (${Math.round(elapsed/1000)}s elapsed)`);
|
|
773
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (fs.existsSync(indexHtmlPath)) {
|
|
777
|
+
console.log('\nā
Reports merged successfully.');
|
|
778
|
+
console.log('\nš Final directory structure:');
|
|
779
|
+
this.printDirectoryTree(summariesDir);
|
|
780
|
+
} else {
|
|
781
|
+
console.warn('\nā ļø Warning: Merged report index.html not found, but continuing...');
|
|
782
|
+
console.log('\nš Final directory structure:');
|
|
783
|
+
this.printDirectoryTree(summariesDir);
|
|
639
784
|
}
|
|
640
|
-
console.log('Reports merged successfully.');
|
|
641
785
|
} catch (error) {
|
|
642
786
|
// Log a warning instead of throwing an error
|
|
643
787
|
console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
|
package/package.json
CHANGED