Configuring the checks
The checks that postdoc test runs on every page are configured under nightwatch.pageChecks. Each of the accessibility checks has settings of its own, described with the check.
Pages, rules and window widths
The checks are configured under nightwatch.pageChecks:
export default {
nightwatch: {
pageChecks: {
// Pages to skip, as URL patterns.
ignore: ['/legacy/**'],
a11y: {
// The part of each page to check.
context: 'main',
// axe run options.
options: {
runOnly: {
type: 'tag',
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']
},
rules: {
'color-contrast': { enabled: false }
}
}
}
}
}
};Pages are checked at the browser's window size, which differs between browsers: headless Chrome opens at 756 by 556 pixels and Firefox at 1366 by 768. To check the same layouts in every browser, such as the desktop and the phone layout, list the window widths:
export default {
nightwatch: {
pageChecks: {
widths: [1280, 390]
}
}
};Each page is then checked once per width, as a test case of its own, such as /guide/index.html at 390px. Menus that only show on small screens are checked only at a small width.
Content that's drawn in the browser, such as diagrams, is checked too, because each page is checked only once its onRender callbacks have finished. A page that isn't ready within 10 seconds fails without being checked. For pages that need longer, raise readyTimeout, in milliseconds:
export default {
nightwatch: {
pageChecks: {
readyTimeout: 20000
}
}
};options are passed to axe as its run options. They replace the default options, so include runOnly to keep checking against the WCAG rules.
To skip the checks for one run, use --skip-page-checks. To turn them off, set pageChecks to false.