cypress-audit
cypress-audit copied to clipboard
JSON file report just recopile the last page launched
I follow the steps to generate a json report and visualize in https://googlechrome.github.io/lighthouse/viewer/ However, the report just shown the last page launched.
What does not work? The report should to show all the pages launched in the spec file
How to reproduce?
- index.js `const { lighthouse, prepareAudit } = require("@cypress-audit/lighthouse"); const fs = require("fs");
module.exports = (on, config) => { on("before:browser:launch", (browser = {}, launchOptions) => { prepareAudit(launchOptions); });
on("task", { lighthouse: lighthouse((lighthouseReport) => { console.log("---- Writing lighthouse report to disk ----");
fs.writeFile("lighthouse.json", lighthouseReport.report, (error) => {
error ? console.log(error) : console.log("Report created successfully");
});
}),
});
};2. scenarios.spec.js
import urls from '../../fixtures/urls.json';
let count = 0;
describe('Lighthouse Accesibility Score ', () => {
urls.forEach(url => { it('Mobile Lighthouse report: ' + urls[count], function () {
const thresholds = {
accessibility: 95,
};
const lighthouseOptions = {
formFactor: 'mobile',
};
cy.visit(url);
cy.lighthouse(thresholds, lighthouseOptions);
});
it('Desktop Lighthouse report: ' + urls[count], function () {
const desktopConfig = {
formFactor: 'desktop',
"screenEmulation": {
"disabled": true
}
};
cy.visit(url);
cy.lighthouse(customThresholds, desktopConfig);
});
count++;
}); }); `
Expected behavior The report json is generated with all the pages launched
Screenshots / Animated Gifs
Environment (please complete the following information):
- OS: macOS Monterey
- Chromium version: 107.0.5297.0 (Developer Build) (arm64)
- Cypress version: 9.7.7
Any other information that may help fixing the issue?
It's not a bug, it's a feature that has not been implemented