I am trying to generate the lighthouse report in html format. But, I am unable to do. I am getting below error:-
Cannot find module 'lighthouse/lighthouse-core/report/report-generator'
I used below link to do configuration for my lighthouse test:-
https://atomfrede.gitlab.io/2021/04/automated-frontend-perfomance-test-with-lighthouse-for-jhipster/
Not sure, what is the error actually, I tried installing lighthouse again and again. Still, no luck.
npm install --save-dev lighthouse
Can anyone help me out here?
Below is the code snippet I have tried:-
const { lighthouse, pa11y, prepareAudit } = require('cypress-audit');
const fs = require('fs');
const ReportGenerator = require('lighthouse/lighthouse-core/report/report-generator');
module.exports = (on, config) => {
on('before:browser:launch', (browser, launchOptions) => {
prepareAudit(launchOptions);
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push('--disable-gpu');
return launchOptions;
}
});
on('task', {
lighthouse: lighthouse((lighthouseReport) => {
fs.writeFileSync('build/cypress/lhreport.html',
ReportGenerator.generateReport(lighthouseReport.lhr, 'html'));
}),
pa11y: pa11y(),
});
};