Skip to content

Commit

Permalink
feature/IVYPORTAL-17377-Create-pipeline-to-run-Lighthouse-report
Browse files Browse the repository at this point in the history
  • Loading branch information
nhthinh-axonivy committed Dec 27, 2024
1 parent a6d3786 commit 134fa7b
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions AxonIvyPortal/portal-selenium-test/lighthouse/puppeteer-script.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,25 @@ const __dirname = dirname(__filename);
}

if (runnerResult && runnerResult.report) {
// Save both HTML files (for compatibility)
const htmlPaths = [
path.join(scriptDir, "lighthouse-report.html"),
path.join(reportsDir, "lighthouse-report.html"),
];

htmlPaths.forEach((htmlPath) => {
fs.writeFileSync(htmlPath, runnerResult.report);
console.log("HTML report saved to:", htmlPath);
});
// Get the HTML report (it's the first output format)
const htmlReport = Array.isArray(runnerResult.report)
? runnerResult.report[0]
: runnerResult.report;

if (typeof htmlReport === "string") {
// Save HTML report in both locations
const htmlPaths = [
path.join(scriptDir, "lighthouse-report.html"),
path.join(reportsDir, "lighthouse-report.html"),
];

htmlPaths.forEach((htmlPath) => {
fs.writeFileSync(htmlPath, htmlReport);
console.log("HTML report saved to:", htmlPath);
});
} else {
throw new Error("HTML report is not a string");
}

// Save JSON report
const jsonPath = path.join(reportsDir, "report.json");
Expand Down

0 comments on commit 134fa7b

Please sign in to comment.