diff --git a/types/jest-axe/index.d.ts b/types/jest-axe/index.d.ts index 191ecb607d..d04364c0fe 100644 --- a/types/jest-axe/index.d.ts +++ b/types/jest-axe/index.d.ts @@ -1,12 +1,13 @@ -// Type definitions for jest-axe 2.2 +// Type definitions for jest-axe 3.2 // Project: https://github.com/nickcolley/jest-axe // Definitions by: Josh Goldberg +// erbridge // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 /// -import { AxeResults, Result, RunOnly } from "axe-core"; +import { AxeResults, Result, RunOnly } from 'axe-core'; /** * Version of the aXe verifier with defaults set. @@ -34,10 +35,7 @@ export interface AxeOptions { * @param options Options to run aXe. * @returns Promise for the results of running aXe. */ -export type JestAxe = ( - html: Element | string, - options?: AxeOptions, -) => Promise; +export type JestAxe = (html: Element | string, options?: AxeOptions) => Promise; /** * Creates a new aXe verifier function. @@ -82,7 +80,7 @@ export const toHaveNoViolations: { declare global { namespace jest { interface Matchers { - toHaveNoViolations: IToHaveNoViolations; + toHaveNoViolations(): R; } } diff --git a/types/jest-axe/jest-axe-tests.ts b/types/jest-axe/jest-axe-tests.ts index 4b95825596..f1b093bdeb 100644 --- a/types/jest-axe/jest-axe-tests.ts +++ b/types/jest-axe/jest-axe-tests.ts @@ -1,4 +1,4 @@ -import { configureAxe, axe, toHaveNoViolations, JestAxe } from "jest-axe"; +import { configureAxe, axe, toHaveNoViolations, JestAxe } from 'jest-axe'; expect.extend(toHaveNoViolations); @@ -9,12 +9,17 @@ const newJestWithOptions: JestAxe = configureAxe({ iframes: false, rules: {}, runOnly: { - type: "rules", + type: 'rules', }, selectors: false, }); const sameJest: JestAxe = axe; -expect("").toHaveNoViolations(); +expect('').toHaveNoViolations(); expect(document.body).toHaveNoViolations(); + +async () => { + expect(await Promise.resolve(document.body)).toHaveNoViolations(); + await expect(Promise.resolve(document.body)).resolves.toHaveNoViolations(); +};