1.4.0 • Published 6 years ago

ha11y v1.4.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

:o: ha11y

Browserless Parallel Accessibility HTML Code Sniffer

Build Status Coverage Status NPM Version XO code style

:man_scientist: Experimental

:o: ha11y is a highly experimental package. The API is subject to rapid change.

Install

npm install --save-dev ha11y

Usage

React

Test:

import React from 'react';
import {shallow} from 'enzyme';
import ha11y from 'ha11y';

import MyImgComp from '../MyImgComp';

it('ha11y test', () => {
    const dom = (
        <html lang="en">
            <head>
                <title>Foo</title>
            </head>
            <body>
                {/* Oops... no ALT tag! */}
                <MyImgComp src="foo.png"/>
            </body>
        </html>
    );

    const html = shallow(dom).html();

    return ha11y.test(html)
        .then(results => {
            const errors = results.filter(result => result.heading === 'ERROR');
            console.log(errors);
            expect(errors.length).toEqual(0);
        });
});

Output:

  FAIL  src/comps/__tests__/passage.test.js
  ● Console
[
    {
        "heading": "ERROR",
        "issue": "WCAG2AAA.Principle1.Guideline1_1.1_1_1.H37",
        "description": "Img element missing an alt attribute. Use the alt attribute to specify a short text alternative.",
        "position": {
            "lineNumber": 1,
            "columnNumber": 0
        },
        "element": {
            "node": "<img src=\"foo.png\">",
            "class": "", 
            "id": ""
        }
    }
]

Licence

Runs on HTML_CodeSniffer see licence.txt

1.4.0

6 years ago

1.3.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago