Skip to content

Commit a60c764

Browse files
committed
added lighthouse performance audit
1 parent 44d7a82 commit a60c764

File tree

5 files changed

+1483
-12
lines changed

5 files changed

+1483
-12
lines changed

cypress.config.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
const { defineConfig } = require("cypress");
2-
2+
const { lighthouse, prepareAudit } = require("@cypress-audit/lighthouse");
33
module.exports = defineConfig({
44
e2e: {
55
setupNodeEvents(on, config) {
66
// implement node event listeners here
7-
},
7+
on("before:browser:launch", (browser = {}, launchOptions) => {
8+
prepareAudit(launchOptions);
9+
}),
10+
on("task", {
11+
lighthouse: lighthouse()
12+
});
13+
}
814
},
915
});

cypress/e2e/home.cy.js

+14
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,18 @@ describe('Judge.Me Site', () => {
4747
it('should validate currency filter to select EUR', () => {
4848
search_po.validateCurrencyFilter()
4949
})
50+
51+
it('should run lighthouse performance audit', () => {
52+
const thresholds = {
53+
performance: 50,
54+
accessibility: 75,
55+
seo: 60,
56+
pwa: 50,
57+
};
58+
const lighthouseConfig = {
59+
formFactor: 'desktop',
60+
screenEmulation: { disabled: true },
61+
};
62+
cy.lighthouse(thresholds, lighthouseConfig);
63+
});
5064
});

cypress/support/commands.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//
2424
// -- This will overwrite an existing command --
2525
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
26+
import '@cypress-audit/lighthouse/commands';
2627

2728
Cypress.Commands.add('performSearch', (keyword) => {
2829
// Enter a keyword in the search bar and press Enter

0 commit comments

Comments
 (0)