Skip to content

Commit

Permalink
Lighthouse (#7)
Browse files Browse the repository at this point in the history
* added latest cypress with cypress-audit

* changed to readme

* audit fix
  • Loading branch information
narayananpalani authored Feb 18, 2021
1 parent 8c1d9d1 commit 9663a4b
Show file tree
Hide file tree
Showing 8 changed files with 1,535 additions and 55 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Book: https://www.routledge.com/Automated-Software-Testing-with-Cypress/Palani/p
7. Jack Cross for cypress-image-snapshot,
8. Lukasz Gandecki for cypress-cucumber-preprocessor.

# Tools required to install prior to use this code:
1. Node version 12 or above
2. Visual Studio Code or IntelliJ or WebstormIDE or any valid IDE

# Dependencies:
1. npm install
2. npm link
Expand Down
11 changes: 10 additions & 1 deletion cypress/integration/features/loginOrangehrmTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ Feature: Login Page Verification on OrangeHRM website
Given I open OrangeHRM homepage
Then I should see title "OrangeHRM"
Then I should see "LOGIN Panel" text displayed
And I should see "Alternative Login" text displayed
And I should see "Alternative Login" text displayed


Scenario: check web page health through lighthouse audit and pa11y audit on valid login page display with login fields
Given I open OrangeHRM homepage
Then I should see title "OrangeHRM"
Then I should see "LOGIN Panel" text displayed
#And I should see "Alternative Login" text displayed
And I should see web audit results
And I should see web accessibility audit results
13 changes: 13 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const cucumber = require("cypress-cucumber-preprocessor").default;
const { lighthouse, pa11y, prepareAudit } = require("cypress-audit");
const getCompareSnapshotsPlugin = require("cypress-visual-regression/dist/plugin");
const {
addMatchImageSnapshotPlugin,
Expand All @@ -29,4 +30,16 @@ module.exports = (on, config) => {

//const file = config.env.configFile;
//return getCongByFile(file);
on("before:browser:launch", (browser = {}, launchOptions) => {
prepareAudit(launchOptions);
});

on("task", {
lighthouse: lighthouse((lighthouseReport) => {
console.log(lighthouseReport); // raw lighthouse reports
}),
pa11y: pa11y((pa11yReport) => {
console.log(pa11yReport); // raw pa11y reports
}),
});
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const compareSnapshotCommand = require("cypress-visual-regression/dist/command");
import { addMatchImageSnapshotCommand } from "cypress-image-snapshot/command";
import "cypress-file-upload";
import "cypress-audit/commands";

Cypress.Commands.add("check_URL_ResponseStatus", (args) => {
cy.get(args).each(($a) => {
Expand Down
8 changes: 8 additions & 0 deletions cypress/support/step_definitions/Shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ Then('I log {string}', (string) => {
Then('I check all URL response status should be 200', function () {
cy.checkURLResponseStatus()
})

Then('I should see web audit results', function () {
cy.lighthouse();
})

Then('I should see web accessibility audit results', function () {
cy.pa11y();
})
Loading

0 comments on commit 9663a4b

Please sign in to comment.