@@ -7,7 +7,7 @@ const browserPromise = playwright.chromium.launch();
7
7
8
8
// Will be replaced by ava.generate-tests.js
9
9
const portNum = process . env . a11yPort || 9002 ;
10
- const stories = [ ] ; //[{name,id,type},...]
10
+ const stories = [ ] ; // [{name,id,type},...]
11
11
12
12
// required macro to allow Playwright tests to run efficiently when using the AVA test runner
13
13
async function pageMacro ( t , callback ) {
@@ -21,30 +21,31 @@ async function pageMacro(t, callback) {
21
21
}
22
22
}
23
23
24
- const prettyPrintObject = ( obj ) =>
25
- Object . keys ( obj ) . map ( key => `${ key } : ${ obj [ key ] } ` ) ;
24
+ const prettyPrintObject = ( obj ) =>
25
+ Object . keys ( obj ) . map ( key => `${ key } : ${ obj [ key ] } ` ) ;
26
26
27
- const generateNodeDescription = ( { html, target, failureSummary} ) =>
28
- prettyPrintObject ( { html, target, failureSummary} ) ;
27
+ const generateNodeDescription = ( { html, target, failureSummary } ) =>
28
+ prettyPrintObject ( { html, target, failureSummary } ) ;
29
29
30
- const generateDescription = ( { id, impact, nodes} , i ) =>
30
+ const generateDescription = ( { id, impact, nodes } , i ) =>
31
31
[
32
- `\nRULE ${ i + 1 } :` ,
33
- prettyPrintObject ( { id, impact} ) . join ( '\n' ) ,
34
- '\nViolation:' ,
35
- nodes . map ( generateNodeDescription ) . map ( x => x . join ( '\n' ) ) . flat ( ) . join ( '\n\n' ) ,
32
+ `\nRULE ${ i + 1 } :` ,
33
+ prettyPrintObject ( { id, impact } ) . join ( '\n' ) ,
34
+ '\nViolation:' ,
35
+ nodes . map ( generateNodeDescription ) . map ( x => x . join ( '\n' ) ) . flat ( ) . join ( '\n\n' ) ,
36
36
'\nFor more info run these tests locally with `npm run test:a11y`\n'
37
37
] ;
38
38
39
39
const generateLink = ( address ) =>
40
- `To view this error, run \`npm start\` and then click this link ${ address } `
40
+ `To view this error, run \`npm start\` and then click this link ${ address } `
41
41
42
42
// repeatable function to run accessibility(a11y) tests for a story
43
43
async function axeTest ( t , page , story , address ) {
44
44
try {
45
45
const results = await new AxeBuilder ( { page } )
46
46
. options ( sa11yPresetRules . recommended )
47
47
. include ( '#root' )
48
+ . exclude ( '#GoogleMapID' )
48
49
. analyze ( ) ;
49
50
50
51
const numViolations = results . violations . length ;
@@ -73,14 +74,14 @@ async function axeTest(t, page, story, address) {
73
74
t . fail ( '!! Error occurred: ' + e ) ;
74
75
}
75
76
}
76
-
77
+
77
78
const runTest = ( story ) => test ( `» a11y: ${ story . kind } /${ story . name } ` , pageMacro , async ( t , page ) => {
78
79
const address = `http://localhost:${ portNum } /iframe.html?id=${ story . id } &args=&viewMode=story` ;
79
80
await page . goto ( address , { timeout : 0 } ) ;
80
81
await axeTest ( t , page , story , address ) ;
81
82
} ) ;
82
83
83
84
// init
84
- ( ( ) => {
85
- stories . forEach ( runTest )
86
- } ) ( )
85
+ ( ( ) => {
86
+ stories . forEach ( runTest )
87
+ } ) ( )
0 commit comments