Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Last active November 17, 2020 00:01
Show Gist options
  • Save TimBHowe/262d73eeb14c43fa48d6c65c388076c1 to your computer and use it in GitHub Desktop.
Save TimBHowe/262d73eeb14c43fa48d6c65c388076c1 to your computer and use it in GitHub Desktop.
A sample Pa11y CI config JavaScript file with all available options with their default settings and notes.
/**
* This is a sample Pa11y CI config JavaScript file with all available options with their default settings and notes.
*
* By default, Pa11y CI looks for a config file in the current working directory, named .pa11yci.JSON file.
* You can use the --config command line argument to specify this JavaScript file.
*
* The purpose of this file is to provide an example configuration file users and experiment with in altering the default settings.
*
* Resources:
* https://github.com/pa11y/pa11y-ci#configuration
* https://github.com/pa11y/pa11y#configuration
*/
module.exports = {
default: {
/**
* Accessability testing standards settings.
*/
standard: "WCAG2AA", //The accessibility standard to use when testing pages. Options: Section508, WCAG2A, WCAG2AA, or WCAG2AAA.
runners: ["htmlcs"], // An array of runner names which correspond to existing and installed Pa11y runners. More Info: https://github.com/pa11y/pa11y#runners
rules: [], // An array of WCAG 2.0 guidelines that you'd like to include to the current standard. Note: These won't be applied to Section508 standard.
includeNotices: false, // Whether to include results with a type of notice in the Pa11y report.
includeWarnings: false, // Whether to include results with a type of warning in the Pa11y report.
level: "error", // The level of issue which can fail the test when running via the CLI. Options: "error", "warning", or "notice".
threshold: 0, // The number of errors, warnings, or notices to permit before the test is considered to have failed.
ignore: [], // An array of result codes and types that you'd like to ignore. You can find the codes for each rule in the console output
reporter: "cli", // The reporter to use while running the test via the CLI. More Info: https://github.com/pa11y/pa11y#reporters.
/**
* An object which implements the methods debug, error, and info which will be used to report errors and test information.
* More Info: https://github.com/pa11y/pa11y#log-object
*/
log: {
debug: "",
error: "",
info: "",
},
/**
* Browser behavior settings.
*/
timeout: 30000, // The time in milliseconds that a test should be allowed to run before calling back with a timeout error.
wait: 0, // The time in milliseconds to wait before running HTML CodeSniffer on the page.
userAgent: "A11Y TESTS", // The User-Agent header to send with Pa11y requests. This is helpful to identify Pa11y in your logs.
headers: {}, // A key-value map of request headers to send when testing a web page.
method: "GET", // The HTTP method to use when running Pa11y.
postData: null, // The HTTP POST data to send when running Pa11y. This should be combined with a Content-Type header.
/**
* The viewport configuration. This can have any of the properties supported by the puppeteer setViewport method.
* More Info: https://github.com/pa11y/pa11y#viewport-object.
*/
viewport: {
// More Info: https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagesetviewportviewport.
width: 1280,
height: 1024,
deviceScaleFactor: 1,
isMobile: false,
hasTouch: false,
isLandscape: false,
},
/**
* Launch options for the Headless Chrome instance.
* More Info: https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#puppeteerlaunchoptions
*/
chromeLaunchConfig: {},
/**
* A Puppeteer Browser instance which will be used in the test run. Optionally you may also supply a Puppeteer Page instance, but this cannot be used between test runs as event listeners would be bound multiple times.
* More Info: https://github.com/pa11y/pa11y#browser-browser-and-page-page
*/
browser: null, // A Browser is created when Puppeteer connects to a Chromium instance.
page: null, // Page provides methods to interact with a single tab or extension background page in Chromium. More Info: https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#class-page.
ignoreUrl: false, // Whether to use the provided Puppeteer Page instance as is or use the provided url. Both the Puppeteer Page instance and the Puppeteer Browser instance are required alongside ignoreUrl.
concurren: 2, // The number of tests that should be run in parallel.
useIncognitoBrowserContext: false, // Run test with an isolated incognito browser context, stops cookies being shared and modified between tests.
/**
* Page interaction settings.
*
* Actions are additional interactions that you can make Pa11y perform before the tests are run. They allow you to do things like click links/button, enter values in a form, wait for a redirect, ect...
* These can be set in default to perform on all URLs or set on individual URLs below.
* More Info: https://github.com/pa11y/pa11y#actions
*/
actions: [],
rootElement: null, // The root element for testing a subset of the page opposed to the full document.
hideElements: "", // A CSS selector to hide elements from testing, selectors can be comma separated. Elements matching this selector will be hidden from testing by styling them with visibility: hidden.
},
/**
* URL to test settings.
*
* An array of URLs to test using the defaults above or their own settings and actions.
* This is overridden by any URL givin in the cli command.
* More Info: https://github.com/pa11y/pa11y-ci/blob/master/README.md#url-configuration.
*/
urls: [],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment