mfrachet / cypress-audit

⚡ Run Lighthouse and Pa11y audits directly in your E2E test suites
https://mfrachet.github.io/cypress-audit/
MIT License
352 stars 43 forks source link

More detailed failure report #191

Open ericmasiello opened 1 year ago

ericmasiello commented 1 year ago

What would you like to see in the library? I am using cypress-audit purely to test for accessibility failures. As such, my tests are very simple, e.g.

describe('Mobile Dock', () => {
    beforeEach(() => {
        cy.visit('/mobile-dock');
    });

    it('should pass lighthouse audit', () => {
        cy.lighthouse({
            accessibility: 100,
        });
    });

    it('should pass pa11y audit', () => {
        cy.pa11y();
    });
});

However, if i my lighthouse score fails, Cypress only reports that it did not meet the 100 value. What I'd like to know is which specific aspects of accessibility it failed on.

Why? This reduces friction in diagnosing accessibility problems. Right now, my only recourse is to manually rerun the same page in Chrome with Lighthouse and look its detailed output to understand why the failure occurred.

Any other information that may help understanding the need N/A

MuckT commented 1 year ago

@ericmasiello try adding this to your cypress.config.ts The results of the audits should now be in your console in .xml but present.

reporter: 'junit',
reporterOptions: {
  mochaFile: 'cypress/results/[hash]-test-output.xml',
  toConsole: true,
},