1 | /**
|
2 | @license
|
3 | Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
|
4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7 | Code distributed by Google as part of the polymer project is also
|
8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9 | */
|
10 | import { ElementContext, RunOptions } from 'axe-core';
|
11 | declare global {
|
12 | namespace axe {
|
13 | const run: typeof import('axe-core').run;
|
14 | }
|
15 | }
|
16 | export interface AxeReportOptions extends RunOptions {
|
17 | cleanup?: () => Promise<void>;
|
18 | axeConfig?: RunOptions;
|
19 | }
|
20 | /**
|
21 | This is an [axe-core](https://github.com/dequelabs/axe-core) reporter that returns an
|
22 | Error containing every a11y violation for an element. Use this if you want to
|
23 | include `axe-core` in automated Mocha tests, etc. Note that this helper does not
|
24 | include `axe-core` for you; you must do this separately.
|
25 |
|
26 | The `axeReport` function takes an optional second argument:
|
27 | {cleanup: {...}, axeConfig: {...}}, where `cleanup` is a callback to be
|
28 | called after the test is ran (so that you can remove the element from the DOM, etc)
|
29 | and `axeConfig` are the optional extra config parameters to pass to axe.
|
30 |
|
31 | Example (in a Mocha test):
|
32 |
|
33 | import 'axe-core/axe.min.js';
|
34 | import { axeReport } from 'pwa-helpers/axe-report.js';
|
35 |
|
36 | describe('button', function() {
|
37 |
|
38 | it('is accessible', function() {
|
39 | const button = document.createElement('button');
|
40 | button.textContent = 'click this'; // Test should fail without this line.
|
41 | return axeReport(button);
|
42 |
|
43 | // If you need to run any cleanup code after the test is run, you
|
44 | // can use the `cleanup` object. For example,
|
45 | // document.body.appendChild(button);
|
46 | // return axeReport(el, { cleanup() { el.remove(); } });
|
47 | });
|
48 | });
|
49 | */
|
50 | export declare function axeReport(dom: ElementContext, config?: AxeReportOptions): Promise<void>;
|