cypress-audit icon indicating copy to clipboard operation
cypress-audit copied to clipboard

JSON file report just recopile the last page launched

Open juanduarte1927 opened this issue 2 years ago • 1 comments

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?

  1. 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.jsimport 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?

juanduarte1927 avatar Sep 13 '22 16:09 juanduarte1927

It's not a bug, it's a feature that has not been implemented

mfrachet avatar Sep 14 '22 04:09 mfrachet