2.1.0 • Published 11 months ago

@financial-times/n-pa11y-config v2.1.0

Weekly downloads
479
License
ISC
Repository
github
Last release
11 months ago

n-pa11y-config CircleCI

This is a module to help creating a Pa11y CI configuration for your project.

Requirements

  • Node version defined by engines.node in package.json. Run command nvm use to switch your local Node version to the one specified in .nvmrc.
  • Pa11y CI

Development

git clone git@github.com:Financial-Times/n-pa11y-config.git
cd n-pa11y-config
npm install

Installation

Install from NPM

npm install --save-dev @financial-times/n-pa11y-config

Usage

Include this library on your .pa11yci.js file and export the result of the invocation of this library:

const nPa11yConfig = require('@financial-times/n-pa11y-config')
const tests = require('./tests/smoke-tests.js')

module.exports = nPa11yConfig({
  tests,
  host: 'http://localhost:3000',
  exceptions: ['__gtg'],
  viewports: [
    {
      width: 640,
      height: 960,
    },
  ],
  headers: {
    'FT-Next-Backend-Key': process.env.FT_NEXT_BACKEND_KEY,
  },
})

Configuration

The function expects an object with the following attributes:

NameDescriptionTypeOptional
testsTests to be tested by Pa11yArrayfalse
hostBase URL to apply to all test routesStringtrue
exceptionsRoutes returning 200 that should not be tested (routes that return something different than 200 will be automatically excluded)Arraytrue
waitThe time to wait before running tests in millisecondsNumbertrue
hideCSS selector to hide elements from testing, selectors can be comma separatedArraytrue
viewportsSet viewports for puppeteerArraytrue
headersHeaders to be added to every test routeObjecttrue
screenCapturePathPath where to store all the screenshots generated by Pa11y. By default it will store all screenshots in screenCapturesStringtrue

Headers

Headers can be set:

  • globally for all apps (in the headers attribute)
  • per test (configured in the tests array)

Headers objects will be merged, cookies and flags will be concatenated. No flags are allowed inside the cookie for easier merging: use the FT-Flags header instead.

Hide

Include in the hide attribute the elements that should not run pa11y (i.e. google ad iFrames) Use with caution. It may break the experience for users.

2.1.0

11 months ago

2.0.0

11 months ago

1.0.0

3 years ago