Socket
Socket
Sign inDemoInstall

axe-core

Package Overview
Dependencies
0
Maintainers
4
Versions
1295
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

axe-core

Accessibility engine for automated Web UI testing


Version published
Maintainers
4
Weekly downloads
15,338,198
decreased by-7.55%

Weekly downloads

Package description

What is axe-core?

The axe-core npm package is a library for accessibility testing. It allows developers to automatically test their HTML for common accessibility issues using a variety of technologies including JavaScript, React, Angular, Vue, and more. The package can be used in different environments like web browsers, Node.js, and continuous integration systems.

What are axe-core's main functionalities?

Accessibility testing in browser

This code sample demonstrates how to run accessibility tests on the current document in a web browser. The results are logged to the console.

axe.run(document, function(err, results) {
  if (err) throw err;
  console.log(results);
});

Integration with testing frameworks

This code sample shows how axe-core can be integrated with Jest testing framework using jest-axe to ensure that a rendered HTML snippet is accessible.

const { axe, toHaveNoViolations } = require('jest-axe');

test('ensures .foo element is accessible', async () => {
  const render = () => '<div class="foo">bar</div>';
  const html = render();
  expect(await axe(html)).toHaveNoViolations();
});

Command-line accessibility testing

This code sample illustrates how to use axe-core with axe-cli for command-line accessibility testing of a given URL.

const axe = require('axe-core');
const { run } = require('axe-cli');

run(axe, { url: 'http://example.com' }, (err, results) => {
  if (err) throw err;
  console.log(results);
});

Other packages similar to axe-core

Readme

Source

axe-core

Join the chat at https://gitter.im/dequelabs/axe-core Version Bower License CircleCI Build Dependency Status Codacy Badge Package Quality

The Accessibility Engine for automated testing of HTML-based user interfaces. Drop the aXe on your accessibility defects!

Philosophy

We believe that automated testing has an important role to play in achieving digital equality and that in order to do that, it must achieve mainstream adoption by professional web developers. That means that the tests must inspire trust, must be fast, must work everywhere and must be available everywhere.

Manifesto

  1. Automated accessibility testing rules must have a zero false-positive rate
  2. Automated accessibility testing rules must be lightweight and fast
  3. Automated accessibility testing rules must work in all modern browsers
  4. Automated accessibility testing rules must, themselves, be tested automatically

The sharp edge of the aXe

aXe is the third generation of accessibility rules for HTML-based user interfaces that differentiates itself from other approaches and rules repositories in the following ways:

  1. It works on all modern browsers,
  2. It supports in-memory fixtures, static fixtures, integration tests and iframes of infinite depth
  3. It has zero false positives (bugs notwithstanding)
  4. It is open source
  5. It is actively supported by a major accessibility vendor
  6. It is designed to work with whatever tools, frameworks, libraries and environments you have today
  7. It is designed to be integrated into your existing functional/acceptance automated tests
  8. It automatically determines which rules to run based on the evaluation context
  9. It is highly configurable

Getting started

First download the package:

npm install axe-core --save-dev

Now include the javascript file in each of your iframes in your fixtures or test systems:

<script src="node_modules/axe-core/axe.min.js" ></script>

Now insert calls at each point in your tests where a new piece of UI becomes visible or exposed:

axe.run(function (err, results) {
	if (err) throw err;
    ok(results.violations.length === 0, 'Should be no accessibility issues');
    // complete the async call
    ...
});

Supported Browsers

The aXe API supports the following browsers:

  • Internet Explorer v9, 10, 11
  • Google Chrome v42 and above
  • Mozilla Firefox v38 and above
  • Apple Safari v7 and above

The Accessibility Rules

The complete list of rules run by axe-core can be found in doc/rule-descriptions.md.

Contents of the API Package

The aXe API package consists of:

  • axe.js - the JavaScript file that should be included in your web site under test (API)
  • axe.min.js - a minified version of the above file

Localization

Axe can be built using your local language. To do so, a localization file must be added to the ./locales directory. This file must have be named in the following manner: <langcode>.json. To build aXe using this locale, instead of the default, run aXe with the --lang flag, like so:

grunt build --lang=nl

This will create a new build for aXe, called axe.<lang>.js and axe.<lang>.min.js. If you want to build localized versions, simply pass in --all-lang instead.

To create a new translation for aXe, start by running grunt translate --lang=<langcode>. This will create a json file fin the ./locales directory, with the default English text in it for you to translate. We welcome any localization for axe-core. For details on how to contribute, see the Contributing section below.

Contributing

Read the Proposing Axe-core Rules guide

Read the documentation on the architecture

Read the documentation on contributing

Projects using axe-core

List of projects using axe-core

Keywords

FAQs

Last updated on 28 Dec 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc