Skip to content

gkemp94/cypress-lighthouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cypress Lighthouse Plugin

accessibilityCypress Lighthouse Plugin is a cypress plugin that adds the cy.lighthouse() command to audit websites against the lighthouse performance metrics. The command runs performance, accessibility, best practices, seo and progressive web app tests using Google's Lighthouse Tool and returns an object with a score out of 1 for each category.

Installation

Use npm or yarn to install cypress-lighthouse

npm install cypress-lighthouse
yarn add cypress-lighthouse

Import the commands in your support/index.js file.

import 'cypress-lighthouse';

API

Syntax

cy.lighthouse(url)

Usage

describe('Performance Metrics for https://google.com', () => {
  before(function () {
    cy.lighthouse('https://google.com').as('results')
  });
  
  it('Meets performance benchmarks', function () {
    // Assert that the performance metric is greater than .85
    cy.wrap(this.results.performance).should('be.gt', .85);
  })
});

Arguments

url (string)

Any valid URL.

Yields

A chaining component with the results of the lighthouse audit.

Example:

{
  "performance": 0.16, 
  "accessibility": 0.72, 
  "best-practices": 0.79, 
  "seo": 0.92, 
  "pwa": 0.3
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

Cypress Plugin for running lighthouse

Resources

Stars

Watchers

Forks

Packages

No packages published