npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pa11y-e2e-tests

v1.0.3

Published

E2E framework for performing accessibility testing using pa11y and puppeteer

Downloads

5

Readme

Run accessibility tests using Pa11y and Puppeteer

This package allows you to run accessibility tests using Pa11y which is an automated testing pal.

Installation

  1. Install the package using command:
npm install -g pa11y-e2e-tests

Configuration

  1. A configuration file should be created in-order to get started with accessibility testing, which will contain pre-defined test settings for running the tests againist browsers etc.

Here's an extract of pa11y.config.js: github.com/pa11y-examples/.../pa11y.config.js

module.exports = {
  launch_url: "https://www.saucedemo.com",
  src_folders: "tests",
  reports_path: "reports",
  reporter: ["json", "html"],
  test_settings: {
    runners: [
      'axe',
      'htmlcs'
    ],
    standard: 'WCAG2A',
    timeout: 120000,
    includeNotices: true,
    includeWarnings: true
  },
  puppeteer_settings: {
    headless: false,
    executablePath: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
  }
};

The above config contains couple of configurations:

  • launch_url : contains the default url to be launched by the browser
  • src_folders: Need to define the folder name which contains tests to be run
  • reports_path: Location to be specified for test results to be saved
  • reporter: Specify the kind of reports needs to be generated. Currently supports 2 formats i.e json and html
  • test_settings: Below are the default settings that will be passed during test execution:

| Name | Types | Default | description | | :---------- |:------: | :------:| ----------------------------------------- | | runners | array | none | An array of runner names which correspond to existing and installed pa11y runners, If runner is not found then pa11y will throw error | | standard | string | WCAG2AA | The accessibility standard to use when testing pages. This should be one of WCAG2A, WCAG2AA, or WCAG2AAA. Note: only used by htmlcs runner | | timeout | integer | none | The time in milliseconds that a test should be allowed to run before calling back with a timeout error.Please note that this is the timeout for the entire test run (including time to initialise Chrome, load the page, and run the tests) | | includeNotices | boolean | false | Whether to include results with a type of notice in the Pa11y report.Issues with a type of notice are not directly actionable and so they are excluded by default. You can include them by using this option | | includeWarnings | boolean | false | Whether to include results with a type of warning in the Pa11y report. Issues with a type of warning are not directly actionable and so they are excluded by default.You can include them by using this option |

  • puppeteer_settings: Puppeteer is used internally to launch the browser. Puppeteer by default uses Chromium in headless mode, however the user can defined the necessary configurations mentioned in the official documentation link
  1. Create a firstTest.js under tests folder :
module.exports = {
  url: `${process.env.BASE_URL}/`,
  actions: [
    'set field #username to standard_user',
    'set field #password to secret_sauce',
    'click element input[name=login-button]',
    'wait for element div[class="app_logo"] to be visible'
  ]
}
  1. Run the command and observe the coverage of a11y (accessibility) issues
  • To run all the tests under tests folder, use command:
npm run runAccessibility
  • To run only a specific test from the tests folder, use command:
runAccessibility --test tests/firstTest.js

Example

Sample repository for references