forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
79 lines (67 loc) · 1.95 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Type definitions for jest-axe 3.5
// Project: https://github.com/nickcolley/jest-axe
// Definitions by: erbridge <https://github.com/erbridge>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 4.3
import { AxeResults, Result, RunOptions, Spec } from 'axe-core';
export interface JestAxeConfigureOptions extends RunOptions {
globalOptions?: Spec | undefined;
}
/**
* Version of the aXe verifier with defaults set.
*
* @remarks You can still pass additional options to this new instance;
* they will be merged with the defaults.
*/
export const axe: JestAxe;
/**
* Runs aXe on HTML.
*
* @param html Raw HTML string to verify with aXe.
* @param options Options to run aXe.
* @returns Promise for the results of running aXe.
*/
export type JestAxe = (html: Element | string, options?: RunOptions) => Promise<AxeResults>;
/**
* Creates a new aXe verifier function.
*
* @param options Options to run aXe.
* @returns New aXe verifier function.
*/
export function configureAxe(options?: JestAxeConfigureOptions): JestAxe;
/**
* Results from asserting whether aXe verification passed.
*/
export interface AssertionsResult {
/**
* Actual checked aXe verification results.
*/
actual: Result[];
/**
* @returns Message from the Jest assertion.
*/
message(): string;
/**
* Whether the assertion passed.
*/
pass: boolean;
}
/**
* Asserts an aXe-verified result has no violations.
*
* @param results aXe verification result, if not running via expect().
* @returns Jest expectations for the aXe result.
*/
export type IToHaveNoViolations = (results?: Partial<AxeResults>) => AssertionsResult;
export const toHaveNoViolations: {
toHaveNoViolations: IToHaveNoViolations;
};
declare module 'expect' {
interface Matchers<R> {
toHaveNoViolations(): R;
}
}
declare global {
// axe-core depends on a global Node
interface Node {}
}