Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
**/cypress/screenshots/**
8 changes: 8 additions & 0 deletions web-testing-2022/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const { defineConfig } = require('cypress');
const { lighthouse, prepareAudit } = require('cypress-audit');

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
on('before:browser:launch', (browser = {}, launchOptions) => {
prepareAudit(launchOptions);
});

on('task', {
lighthouse: lighthouse(),
});
},
baseUrl: 'http://localhost:3000',
},
Expand Down
21 changes: 21 additions & 0 deletions web-testing-2022/cypress/e2e/perf.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference types="cypress" />

describe('The App', () => {
it('meets performance and accessibility standards', () => {
const thresholds = {
performance: 100,
accessibility: 100,
seo: 100,
pwa: 100,
};

// https://github.com/GoogleChrome/lighthouse/blob/main/docs/emulation.md
// const lighthouseConfig = {
// formFactor: 'desktop',
// screenEmulation: { disabled: true },
// };

cy.visit('/');
cy.lighthouse(thresholds);
});
});
1 change: 1 addition & 0 deletions web-testing-2022/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import 'cypress-audit/commands';
4 changes: 3 additions & 1 deletion web-testing-2022/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"web-vitals": "^2.1.4"
},
"devDependencies": {
"cypress": "^10.4.0"
"cypress": "^10.4.0",
"cypress-audit": "^1.1.0"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -26,6 +27,7 @@
"eject": "react-scripts eject",
"test:cy:ci": "npx cypress run --spec '**/**/solution.cy.js' --browser=chrome",
"test:cy:sanity": "npx cypress run --spec '**/**/sanity.cy.js' --browser=chrome",
"test:perf": "npx cypress run --spec '**/**/perf.cy.js' --browser=chrome --headed",
"test:visual": "npx happo-e2e -- npx cypress run --spec 'cypress/e2e/visual.cy.js'",
"test:sanity": "npm run test:cy:sanity && npm run test:visual"
},
Expand Down