-
Notifications
You must be signed in to change notification settings - Fork 23
/
jest-axe.d.ts
80 lines (70 loc) · 1.88 KB
/
jest-axe.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
80
// Types extracted from https://www.npmjs.com/package/@types/jest-axe
// because `jest-axe` depends on `@types/jest`, which we don't want
// because we use `@jest/globals`
declare module 'jest-axe' {
import type {
AxeResults,
ImpactValue,
Result,
RunOptions,
Spec,
} from 'axe-core'
export type JestAxeConfigureOptions = {
globalOptions?: Spec | undefined
impactLevels?: ImpactValue[]
} & RunOptions
/**
* 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 type 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
}
}