(
page: Page,
{ url, ruleIds, timeout }: AxeUrlArgs,
)
| 155 | } |
| 156 | |
| 157 | async function analyzePage( |
| 158 | page: Page, |
| 159 | { url, ruleIds, timeout }: AxeUrlArgs, |
| 160 | ): Promise<AxeResults> { |
| 161 | await page.goto(url, { |
| 162 | waitUntil: 'networkidle', |
| 163 | timeout, |
| 164 | }); |
| 165 | |
| 166 | const axeBuilder = new AxeBuilder({ page }); |
| 167 | |
| 168 | // Use withRules() to include experimental/deprecated rules |
| 169 | if (ruleIds.length > 0) { |
| 170 | axeBuilder.withRules(ruleIds); |
| 171 | } |
| 172 | |
| 173 | const results = await axeBuilder.analyze(); |
| 174 | |
| 175 | logger.debug( |
| 176 | formatAsciiTable({ |
| 177 | columns: ['left', 'right'], |
| 178 | rows: [ |
| 179 | ['Passes', results.passes.length], |
| 180 | ['Violations', results.violations.length], |
| 181 | ['Incomplete', results.incomplete.length], |
| 182 | ['Inapplicable', results.inapplicable.length], |
| 183 | ], |
| 184 | }), |
| 185 | ); |
| 186 | |
| 187 | if (results.incomplete.length > 0) { |
| 188 | logger.warn( |
| 189 | `Axe returned ${pluralizeToken('incomplete result', results.incomplete.length)}`, |
| 190 | ); |
| 191 | logger.debug( |
| 192 | results.incomplete |
| 193 | .flatMap(res => [ |
| 194 | `• ${res.id}`, |
| 195 | indentLines( |
| 196 | res.nodes |
| 197 | .flatMap(node => [...node.all, ...node.any]) |
| 198 | .map(check => `- ${check.message}`) |
| 199 | .join('\n'), |
| 200 | 2, |
| 201 | ), |
| 202 | ]) |
| 203 | .join('\n'), |
| 204 | ); |
| 205 | } |
| 206 | |
| 207 | return results; |
| 208 | } |
no test coverage detected