Gathering detailed insights and metrics for cypress-audit
Gathering detailed insights and metrics for cypress-audit
Gathering detailed insights and metrics for cypress-audit
Gathering detailed insights and metrics for cypress-audit
⚡ Run Lighthouse and Pa11y audits directly in your E2E test suites
npm install cypress-audit
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
358 Stars
115 Commits
46 Forks
4 Watchers
4 Branches
11 Contributors
Updated on Jun 20, 2025
Latest Version
1.1.0
Package Id
cypress-audit@1.1.0
Unpacked Size
2.18 MB
Size
1.90 MB
File Count
23
NPM Version
6.14.11
Node Version
14.16.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
5
We have the chance of being able to use powerful tools to automated and prevent from different kind of regressions:
While these tools are amazingly powerful and helpful, I'm always feeling in pain when I try to use all of them in my projects.
For example, how can I verify the performance and accessibility status of a page requiring authentication? I have to tweak Lighthouse and Pa11y configurations (that are different) and adjust my workflows accordingly.
This is cumbersome because I already have my authentication logic and shortcuts managed by Cypress: why should I add more complexity in my tests?
The idea behind cypress-audit
is to aggregate all the underlying configurations behind dedicated Cypress custom commands: you can benefit from your own custom commands and you can run cross-cutting verifications directly inside your tests.
In order to make cypress-audit
commands available in your project, there are 3 steps to follow:
In your favorite terminal:
1$ yarn add -D cypress-audit 2# or 3$ npm install --save-dev cypress-audit
By default, if you try to run Lighthouse or Pa11y from the command line (or from Nodejs), you will see that they both open a new web browser window by default. As you may also know, Cypress also opens a dedicated browser to run its tests.
The following configuration allows Lighthouse, Pa11y and Cypress to make their verifications inside the same browser (controlled by Cypress) instead of opening a new one.
In the cypress/plugins/index.js
file, make sure to have:
1const { lighthouse, pa11y, prepareAudit } = require("cypress-audit"); 2 3module.exports = (on, config) => { 4 on("before:browser:launch", (browser = {}, launchOptions) => { 5 prepareAudit(launchOptions); 6 }); 7 8 on("task", { 9 lighthouse: lighthouse(), // calling the function is important 10 pa11y: pa11y(), // calling the function is important 11 }); 12};
When adding the following line in the cypress/support/commands.js
file, you will be able to use cy.lighthouse
and cy.pa11y
inside your Cypress tests:
1import "cypress-audit/commands";
After completing the Preparation section, you can use the cy.lighthouse
and cy.pa11y
commands:
1it("should pass the audits", function () { 2 cy.lighthouse(); 3 cy.pa11y(); 4});
ℹ️ When running the different audits, a new tab will open. It's normal. Lighthouse works that way and I don't think we can manage this otherwise (if you know how, please reach out to me :pray:).
When using custom tools, it can be convenient to directly access the raw information they provide for doing manual things, such as generating a custom reports.
To do so, you can pass a callback
function to the task initializer. Then, when an audit is run, this callback will we executed with the raw data of the underlying tool.
In the cypress/plugins/index.js
file:
1const { lighthouse, pa11y, prepareAudit } = require("cypress-audit"); 2 3module.exports = (on, config) => { 4 on("before:browser:launch", (browser = {}, launchOptions) => { 5 prepareAudit(launchOptions); 6 }); 7 8 on("task", { 9 lighthouse: lighthouse((lighthouseReport) => { 10 console.log(lighthouseReport); // raw lighthouse reports 11 }), 12 pa11y: pa11y((pa11yReport) => { 13 console.log(pa11yReport); // raw pa11y reports 14 }), 15 }); 16};
In order to verify the state of this projects, automated tests are run on CI on examples projects. These projects are located in the examples folder and contain audits for:
If you have a specific configuration or are running using a specific tool, you can add a project example and make it part of the CI process.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 6/29 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
82 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More