playwright-slack-report-burak 3.0.27 → 3.0.29

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.
@@ -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,18 +677,45 @@ 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)...');
611
689
  try {
612
- // Merge blob reports - use relative path from summariesDir and output to mergedBlobsDir
690
+ // Merge blob reports - use absolute path for output-dir to ensure it works correctly
613
691
  // This prevents wiping the playwright-report directory
614
692
  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 });
693
+ const mergedBlobsAbsolutePath = path.resolve(mergedBlobsDir);
694
+ console.log(`Merging blob reports from: ${blobReportsRelativePath}`);
695
+ console.log(`Output directory: ${mergedBlobsAbsolutePath}`);
696
+ const mergeCommand = `npx playwright merge-reports --reporter html --output-dir "${mergedBlobsAbsolutePath}" "${blobReportsRelativePath}"`;
697
+ console.log(`Executing: ${mergeCommand}`);
698
+ const mergeResult = await execAsync(mergeCommand, { cwd: summariesDir });
699
+ console.log('Merge command output:', mergeResult.stdout);
700
+ if (mergeResult.stderr) {
701
+ console.warn('Merge command stderr:', mergeResult.stderr);
702
+ }
617
703
  console.log('Blob reports merged successfully with traces preserved.');
704
+
705
+ // Show directory structure after merge
706
+ console.log('\nšŸ“ Directory structure after merge:');
707
+ this.printDirectoryTree(summariesDir);
708
+ console.log('\nšŸ“ Merged blobs directory contents:');
709
+ this.printDirectoryTree(mergedBlobsDir);
618
710
  } catch (error) {
619
711
  console.warn('Warning: Failed to merge blob reports. Falling back to HTML merge.', error.message);
712
+ if (error.stdout) console.log('Merge stdout:', error.stdout);
713
+ if (error.stderr) console.warn('Merge stderr:', error.stderr);
714
+
715
+ // Show directory structure after failed merge
716
+ console.log('\nšŸ“ Directory structure after failed merge:');
717
+ this.printDirectoryTree(summariesDir);
718
+
620
719
  // Fallback to HTML merge
621
720
  execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
622
721
  }
@@ -626,18 +725,40 @@ class ResultsParser {
626
725
  execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
627
726
  }
628
727
 
629
- // Wait until index.html exists in mergedBlobsDir
630
- while (!fs.existsSync(path.join(mergedBlobsDir, 'index.html'))) {
631
- console.log('Waiting 2 seconds for merged html report to be generated...');
632
- const currentTime = new Date().getTime();
633
- breakMergeWaiter = false;
634
- while (!breakMergeWaiter) {
635
- if(new Date().getTime() - currentTime > 2000) {
636
- breakMergeWaiter = true;
728
+ // Wait until index.html exists in mergedBlobsDir (with timeout)
729
+ const maxWaitTime = 60000; // 60 seconds max wait
730
+ const startWaitTime = new Date().getTime();
731
+ const indexHtmlPath = path.join(mergedBlobsDir, 'index.html');
732
+
733
+ console.log('\nā³ Waiting for merged HTML report to be generated...');
734
+ while (!fs.existsSync(indexHtmlPath)) {
735
+ const elapsed = new Date().getTime() - startWaitTime;
736
+ if (elapsed > maxWaitTime) {
737
+ console.warn(`\nā±ļø Timeout: index.html not found in ${mergedBlobsDir} after ${maxWaitTime}ms`);
738
+ console.log(`Checking if directory exists: ${fs.existsSync(mergedBlobsDir)}`);
739
+ if (fs.existsSync(mergedBlobsDir)) {
740
+ console.log('\nšŸ“ Full directory tree at timeout:');
741
+ this.printDirectoryTree(summariesDir);
742
+ console.log('\nšŸ“ Merged blobs directory detailed contents:');
743
+ this.printDirectoryTree(mergedBlobsDir);
744
+ } else {
745
+ console.log('Merged blobs directory does not exist!');
637
746
  }
747
+ break;
638
748
  }
749
+ console.log(`Waiting for merged html report to be generated... (${Math.round(elapsed/1000)}s elapsed)`);
750
+ await new Promise(resolve => setTimeout(resolve, 2000));
751
+ }
752
+
753
+ if (fs.existsSync(indexHtmlPath)) {
754
+ console.log('\nāœ… Reports merged successfully.');
755
+ console.log('\nšŸ“ Final directory structure:');
756
+ this.printDirectoryTree(summariesDir);
757
+ } else {
758
+ console.warn('\nāš ļø Warning: Merged report index.html not found, but continuing...');
759
+ console.log('\nšŸ“ Final directory structure:');
760
+ this.printDirectoryTree(summariesDir);
639
761
  }
640
- console.log('Reports merged successfully.');
641
762
  } catch (error) {
642
763
  // Log a warning instead of throwing an error
643
764
  console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "lint-fix": "npx eslint . --ext .ts --fix"
33
33
  },
34
34
  "name": "playwright-slack-report-burak",
35
- "version": "3.0.27",
35
+ "version": "3.0.29",
36
36
  "main": "index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "author": "Burak B. <burak.boluk@hotmail.com>",