Lighthouse Runner for within Cypress
npm install cypress-lighthousecy.lighthouse command to audit websites against the lighthouse performance metrics.
npm install cypress-lighthouse
`
`
yarn add cypress-lighthouse
`Import the commands at the top of your test file.
`
import 'cypress-lighthouse';
`API
$3
`javascript
.lighthouse(url)
`
$3
`javascript
describe('Performance Metrics for https://google.com', () => {
before(function () {
cy.lighthouse('https://google.com').as('results')
});
it('Meets performance benchmarks', function () {
// Assert that the performance metric is greater than .85
cy.wrap(this.results.performance).should('be.gt', .85);
})
});
`
$3
url (string)
Any valid URL.$3
A chaining component with the results of the lighthouse audit.
Example:
`json
{
"performance": 0.16,
"accessibility": 0.72,
"best-practices": 0.79,
"seo": 0.92,
"pwa": 0.3
}
``Please make sure to update tests as appropriate.