Analyzes a URL for accessibility issues using Axe.
(args: AxeUrlArgs)
| 45 | |
| 46 | /** Analyzes a URL for accessibility issues using Axe. */ |
| 47 | async analyzeUrl(args: AxeUrlArgs): Promise<AxeUrlResult> { |
| 48 | const browser = await this.launchBrowser(); |
| 49 | const { url, urlIndex, urlsCount } = args; |
| 50 | const prefix = ansis.gray(`[${urlIndex + 1}/${urlsCount}]`); |
| 51 | |
| 52 | return await logger.task(`${prefix} Analyzing URL ${url}`, async () => { |
| 53 | const context = await browser.newContext({ |
| 54 | ...(this.storageState && { storageState: this.storageState }), |
| 55 | }); |
| 56 | |
| 57 | try { |
| 58 | const page = await context.newPage(); |
| 59 | try { |
| 60 | const axeResults = await analyzePage(page, args); |
| 61 | const auditOutputs = toAuditOutputs(axeResults, url); |
| 62 | return { |
| 63 | message: `${prefix} Analyzed URL ${url}`, |
| 64 | result: { url, axeResults, auditOutputs }, |
| 65 | }; |
| 66 | } finally { |
| 67 | await page.close(); |
| 68 | } |
| 69 | } finally { |
| 70 | await context.close(); |
| 71 | } |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | /** Runs setup script and captures authentication state for reuse. */ |
| 76 | async captureAuthState( |
no test coverage detected