Run Lighthouse and Pa11y audits directly in Cypress test suites
The first tool that most engineers probably associate with front end or client side performance testing is Google Lighthouse. So when I stumbled upon a Cypress plugin which lets you run Lighthouse audits directly from your Cypress tests, I had to share this knowledge with the community.
The following tools and applications are used in doing the audit.
- Cypress - The web has evolved. Finally, testing has too. Fast, easy and reliable testing for anything that runs in a browser.
- Lighthouse - To perform Performance audit with various parameters
- Pa11y - Tools to analyze and improve the accessibility status of applications
This is an example repository to showcase how you can use cypress-audit to easily integrate lighthouse commands into your Cypress tests.
- Clone the repository
- In the root folder run
npm install
to get all the dependencies required to run the test
The following things are configured as part of creating this demo.
- Node.js and npm is installed in the system.
- Cypress is installed in a folder in home directory.
- Information on adding dependencies for importing
cypress-audit
library is added in support folder. - Information on adding Lighthouse and Report Configuration is added in plugin folder.
- Information on Test Case and Parameter for running the test is added in integration folder.
- Cypress.json consist of BaseUrl and default timeouts which can be changed based on need.
- package-lock.json consist of all the npm dependencies required to run Cypress and Lighthouse.