diff --git a/types/axe-webdriverjs/axe-webdriverjs-tests.ts b/types/axe-webdriverjs/axe-webdriverjs-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/axe-webdriverjs/index.d.ts b/types/axe-webdriverjs/index.d.ts new file mode 100644 index 0000000000..d8e3979145 --- /dev/null +++ b/types/axe-webdriverjs/index.d.ts @@ -0,0 +1,79 @@ +// Type definitions for axe-webdriverjs 2.0 +// Project: https://github.com/dequelabs/axe-webdriverjs#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Result, RunOptions, Spec } from "axe-core"; +import { WebDriver } from "selenium-webdriver"; + +export interface IAxeAnalysis { + inapplicable: Result[]; + incomplete: Result[]; + passes: Result[]; + timestamp: string; + url: string; + violations: Result[]; +} + +export interface AxeBuilder { + (driver: WebDriver): AxeBuilder; + new (driver: WebDriver): AxeBuilder; + + /** + * Includes a selector in analysis. + * + * @param selector CSS selector of the element to include. + */ + include(selector: string): this; + + /** + * Excludes a selector from analysis. + * + * @param selector CSS selector of the element to exclude. + */ + exclude(selector: string): this; + + /** + * Options to directly pass to `axe.run`. + * + * @param options aXe options object. + * @remarks Will override any other configured options, including calls to `withRules` and `withTags`. + */ + options(options: RunOptions): this; + + /** + * Limits analysis to only the specified rules. + * + * @param rules Array of rule IDs, or a single rule ID as a string. + * @remarks Cannot be used with `withTags`. + */ + withRules(rules: string | string[]): this; + + /** + * Limist analysis to only the specified tags. + * + * @param rules Array of tags, or a single tag as a string + * @remarks Cannot be used with `withRules`. + */ + withTags(tags: string | string[]): this; + + /** + * Set the list of rules to skip when running an analysis + * + * @param rules Array of rule IDs, or a single rule ID as a string + */ + disableRules(rules: string | string[]): this; + + /** + * Configures aXe before running analyze. + * + * @param config aXe Configuration spec to use in analysis. + */ + configure(config: Spec): this; + + /** + * Perform analysis and retrieve results. + * @param callback Function to execute when analysis completes. + */ + analyze(callback: (results: IAxeAnalysis) => void): Promise; +} diff --git a/types/axe-webdriverjs/package.json b/types/axe-webdriverjs/package.json new file mode 100644 index 0000000000..5d94289f3b --- /dev/null +++ b/types/axe-webdriverjs/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "dependencies": { + "@types/selenium-webdriver": "^3.0.0", + "axe-core": "^2.6.1" + } +} diff --git a/types/axe-webdriverjs/tsconfig.json b/types/axe-webdriverjs/tsconfig.json new file mode 100644 index 0000000000..efa6dfcf98 --- /dev/null +++ b/types/axe-webdriverjs/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "axe-webdriverjs-tests.ts" + ] +} diff --git a/types/axe-webdriverjs/tslint.json b/types/axe-webdriverjs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/axe-webdriverjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }