playwright-slack-report-burak 3.0.38 → 3.0.40
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 +45 -51
- package/package.json +1 -1
|
@@ -18,9 +18,10 @@ try {
|
|
|
18
18
|
AdmZip = null;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const SUMMARIES_DIR = path.join('./', 'playwright-
|
|
21
|
+
const SUMMARIES_DIR = path.join('./', 'playwright-artifacts');
|
|
22
22
|
const NODE_ARTIFACTS_DIR = path.join(SUMMARIES_DIR, 'nodeArtifacts');
|
|
23
|
-
const
|
|
23
|
+
const PLAYWRIGHT_REPORT_DIR = path.join('./', 'playwright-report');
|
|
24
|
+
const FINAL_OUTPUT_DIR = path.join('./', 'playwright-report');
|
|
24
25
|
|
|
25
26
|
class ResultsParser {
|
|
26
27
|
result;
|
|
@@ -54,15 +55,15 @@ class ResultsParser {
|
|
|
54
55
|
}*/
|
|
55
56
|
|
|
56
57
|
// Define the directory to store node summaries
|
|
57
|
-
if (!fs.existsSync(
|
|
58
|
-
fs.mkdirSync(
|
|
58
|
+
if (!fs.existsSync(PLAYWRIGHT_REPORT_DIR)) {
|
|
59
|
+
fs.mkdirSync(PLAYWRIGHT_REPORT_DIR, { recursive: true });
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
// Determine the current node index
|
|
62
63
|
const currentNodeIndex = this.shardIndex;
|
|
63
64
|
|
|
64
65
|
// Define the file for the current node's summary
|
|
65
|
-
const nodeSummaryFile = path.join(
|
|
66
|
+
const nodeSummaryFile = path.join(PLAYWRIGHT_REPORT_DIR, `node_summary_${currentNodeIndex}.json`);
|
|
66
67
|
|
|
67
68
|
const totalTestCasesForNode = this.result.reduce((acc, suite) => acc + suite.testSuite.tests.length, 0);
|
|
68
69
|
|
|
@@ -339,38 +340,23 @@ class ResultsParser {
|
|
|
339
340
|
}
|
|
340
341
|
|
|
341
342
|
async fetchAllArtifacts() {
|
|
342
|
-
// Ensure
|
|
343
|
+
// Ensure summaries directory exists
|
|
343
344
|
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
344
345
|
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
345
346
|
}
|
|
346
347
|
|
|
347
|
-
// Create nodeArtifacts directory under
|
|
348
|
+
// Create nodeArtifacts directory under summaries
|
|
348
349
|
if (!fs.existsSync(NODE_ARTIFACTS_DIR)) {
|
|
349
350
|
fs.mkdirSync(NODE_ARTIFACTS_DIR, { recursive: true });
|
|
350
351
|
}
|
|
351
352
|
|
|
352
|
-
// Copy
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const node1BlobDest = path.join(NODE_ARTIFACTS_DIR, 'blob-report-node-1.zip');
|
|
361
|
-
let node1BlobCopied = false;
|
|
362
|
-
|
|
363
|
-
for (const source of possibleNode1BlobSources) {
|
|
364
|
-
if (fs.existsSync(source)) {
|
|
365
|
-
fs.copyFileSync(source, node1BlobDest);
|
|
366
|
-
console.log(`Copied ${source} to nodeArtifacts`);
|
|
367
|
-
node1BlobCopied = true;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (!node1BlobCopied) {
|
|
373
|
-
console.warn('Warning: blob-report-node-1.zip not found in expected locations');
|
|
353
|
+
// Copy entire contents of playwright-report to NODE_ARTIFACTS_DIR
|
|
354
|
+
const playwrightReportDir = path.join('./', 'playwright-report');
|
|
355
|
+
if (fs.existsSync(playwrightReportDir)) {
|
|
356
|
+
this.copyDirectoryRecursive(playwrightReportDir, NODE_ARTIFACTS_DIR);
|
|
357
|
+
console.log(`Copied entire contents of playwright-report to ${NODE_ARTIFACTS_DIR}`);
|
|
358
|
+
} else {
|
|
359
|
+
console.warn('Warning: playwright-report directory not found');
|
|
374
360
|
}
|
|
375
361
|
|
|
376
362
|
while (!this.allNodeSummaryFilesExist() || !this.allBlobZipsExist()) {
|
|
@@ -443,7 +429,7 @@ class ResultsParser {
|
|
|
443
429
|
|
|
444
430
|
// Extract ZIP and find the specific file
|
|
445
431
|
const zip = new AdmZip(downloadResponse.data);
|
|
446
|
-
const zipEntry = zip.getEntry(file) || zip.getEntry(`playwright-
|
|
432
|
+
const zipEntry = zip.getEntry(file) || zip.getEntry(`playwright-artifacts/${file}`);
|
|
447
433
|
|
|
448
434
|
if (zipEntry) {
|
|
449
435
|
fs.writeFileSync(filePath, zipEntry.getData());
|
|
@@ -471,38 +457,27 @@ class ResultsParser {
|
|
|
471
457
|
mergeReports() {
|
|
472
458
|
let breakMergeWaiter = false;
|
|
473
459
|
try {
|
|
474
|
-
// Ensure playwright-report directory exists
|
|
475
|
-
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
476
|
-
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
477
|
-
}
|
|
478
460
|
|
|
479
|
-
//
|
|
480
|
-
if (!fs.existsSync(FINAL_OUTPUT_DIR)) {
|
|
481
|
-
fs.mkdirSync(FINAL_OUTPUT_DIR, { recursive: true });
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// Copy blob files before merging (Playwright merge-reports expects blob files)
|
|
485
|
-
// We'll copy them to FINAL_OUTPUT_DIR for merging, then extract later for resource copying
|
|
486
|
-
|
|
487
|
-
// Copy all blob zip files to FINAL_OUTPUT_DIR for merging
|
|
461
|
+
// Copy all blob files to playwright-report before merging
|
|
488
462
|
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
489
463
|
const blobZipFile = path.join(NODE_ARTIFACTS_DIR, `blob-report-node-${i}.zip`);
|
|
490
464
|
if (fs.existsSync(blobZipFile)) {
|
|
491
465
|
try {
|
|
492
|
-
const destFile = path.join(
|
|
466
|
+
const destFile = path.join(PLAYWRIGHT_REPORT_DIR, `blob-report-node-${i}.zip`);
|
|
493
467
|
fs.copyFileSync(blobZipFile, destFile);
|
|
494
|
-
console.log(`Copied blob-report-node-${i}.zip for merging`);
|
|
468
|
+
console.log(`Copied blob-report-node-${i}.zip to playwright-report for merging`);
|
|
495
469
|
} catch (error) {
|
|
496
470
|
console.warn(`Failed to copy blob-report-node-${i}.zip for merging:`, error.message);
|
|
497
471
|
}
|
|
498
472
|
}
|
|
499
473
|
}
|
|
500
474
|
|
|
501
|
-
// Execute the command to merge reports
|
|
502
|
-
|
|
475
|
+
// Execute the command to merge reports FROM playwright-report
|
|
476
|
+
// Playwright will output to playwright-report directory
|
|
477
|
+
exec(`npx playwright merge-reports --reporter html ${PLAYWRIGHT_REPORT_DIR}`);
|
|
503
478
|
|
|
504
|
-
// Wait until index.html exists in
|
|
505
|
-
while (!fs.existsSync(path.join(
|
|
479
|
+
// Wait until index.html exists in playwright-report
|
|
480
|
+
while (!fs.existsSync(path.join(PLAYWRIGHT_REPORT_DIR, 'index.html'))) {
|
|
506
481
|
console.log('Waiting 2 seconds for merged html report to be generated...');
|
|
507
482
|
const currentTime = new Date().getTime();
|
|
508
483
|
breakMergeWaiter = false;
|
|
@@ -514,14 +489,33 @@ class ResultsParser {
|
|
|
514
489
|
}
|
|
515
490
|
console.log('Reports merged successfully.');
|
|
516
491
|
|
|
517
|
-
//
|
|
518
|
-
this.unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR,
|
|
492
|
+
// After merge, extract all blobs from nodeArtifacts to playwright-report
|
|
493
|
+
this.unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR, PLAYWRIGHT_REPORT_DIR);
|
|
519
494
|
} catch (error) {
|
|
520
495
|
// Log a warning instead of throwing an error
|
|
521
496
|
console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
|
|
522
497
|
}
|
|
523
498
|
}
|
|
524
499
|
|
|
500
|
+
copyDirectoryRecursive(srcDir, destDir) {
|
|
501
|
+
if (!fs.existsSync(destDir)) {
|
|
502
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
const entries = fs.readdirSync(srcDir, { withFileTypes: true });
|
|
506
|
+
|
|
507
|
+
for (const entry of entries) {
|
|
508
|
+
const srcPath = path.join(srcDir, entry.name);
|
|
509
|
+
const destPath = path.join(destDir, entry.name);
|
|
510
|
+
|
|
511
|
+
if (entry.isDirectory()) {
|
|
512
|
+
this.copyDirectoryRecursive(srcPath, destPath);
|
|
513
|
+
} else {
|
|
514
|
+
fs.copyFileSync(srcPath, destPath);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
525
519
|
unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR, FINAL_OUTPUT_DIR) {
|
|
526
520
|
if (!AdmZip) {
|
|
527
521
|
console.error('adm-zip is required for blob extraction. Please install it: npm install adm-zip');
|
package/package.json
CHANGED