nightwatch-accessibility

Nightwatch.js utility assertion for accessibility testing with aXe.

Usage no npm install needed!

<script type="module">
  import nightwatchAccessibility from 'https://cdn.skypack.dev/nightwatch-accessibility';
</script>

README

Nightwatch Accessibility

Nightwatch.js utility assertion for accessibility testing with aXe.

license release super linter test semantic

Install

npm install --only=production --save nightwatch-accessibility

Usage

Update your nightwatch config:

{
  custom_commands_path: ["./node_modules/nightwatch-accessibility/commands"],
  custom_assertions_path: ["./node_modules/nightwatch-accessibility/assertions"]
}

Use in your tests:

module.exports = {
  'Test': function (browser) {
    browser
      .initAccessibility()
      .assert.accessibility('#app', {
        verbose: true,
        rules: {
          'color-contrast': { enabled: false }
        }
      })
      .end()
  }
}

API

browser.initAccessibility()

Injects the aXe library into the current test page.

browser.assert.accessibility(context, options)

Analyzes the defined context against applied aXe rules

Name Type Default Description
context String 'html' aXe Context Parameter
options Object null aXe Options Parameter

In addition to the standard options:

  • options.verbose set to true will log all successful aXe tests.
  • options.timeout configures the nightwatch timeout, default value is 500 milliseconds

Author: Ahmad Nassri • Twitter: @AhmadNassri