Skip to content

Commit 732fe76

Browse files
authored
feat: Add type definition for client.auditAccessibility method (#563)
* feat: Add type definition for client.auditAccessibility method * fix: Linting error, replace Array<> by []
1 parent 9c21121 commit 732fe76

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

lib/spectron.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,61 @@ declare module "spectron" {
88
import * as Electron from "electron";
99
import * as WebdriverIO from "webdriverio";
1010

11+
interface AccessibilityAuditOptions {
12+
/**
13+
* true to ignore failures with a severity of 'Warning' and only
14+
* include failures with a severity of 'Severe'. Defaults to false.
15+
*/
16+
ignoreWarnings?:boolean;
17+
18+
/**
19+
* Rule code values such as AX_COLOR_01 to ignore failures for.
20+
*/
21+
ignoreRules?:string[];
22+
}
23+
24+
interface AccessibilityAuditResult {
25+
/**
26+
* False when the audit has failures
27+
*/
28+
failed:boolean;
29+
30+
/**
31+
* A detailed message about the results
32+
*/
33+
message:string;
34+
35+
/**
36+
* An array of detail objects for each failed rule
37+
*/
38+
results:{
39+
/**
40+
* A unique accessibility rule identifier
41+
*/
42+
code:string;
43+
44+
/**
45+
* Selector path of each HTML element that failed the rule
46+
*/
47+
elements:string[];
48+
49+
/**
50+
* A String message about the failed rule
51+
*/
52+
message:string;
53+
54+
/**
55+
* 'Warning' or 'Severe'
56+
*/
57+
severity:'Warning' | 'Severe';
58+
59+
/**
60+
* URL providing more details about the failed rule
61+
*/
62+
url:string;
63+
}[];
64+
}
65+
1166
export interface SpectronClient extends WebdriverIO.Client<void> {
1267
/**
1368
* Focus a window using its title or URL.
@@ -50,6 +105,11 @@ declare module "spectron" {
50105
* The logs are cleared after they are returned.
51106
*/
52107
getMainProcessLogs():Promise<string[]>;
108+
109+
/**
110+
* Run an accessibility audit in the focused window with the specified options.
111+
*/
112+
auditAccessibility(options?:AccessibilityAuditOptions):Promise<AccessibilityAuditResult>;
53113
}
54114

55115
export interface SpectronWindow extends Electron.BrowserWindow {

0 commit comments

Comments
 (0)