MCPcopy Create free account
hub / github.com/code-pushup/cli / analyzePage

Function analyzePage

packages/plugin-axe/src/lib/runner/run-axe.ts:157–208  ·  view source on GitHub ↗
(
  page: Page,
  { url, ruleIds, timeout }: AxeUrlArgs,
)

Source from the content-addressed store, hash-verified

155}
156
157async 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}

Callers 1

analyzeUrlMethod · 0.85

Calls 5

formatAsciiTableFunction · 0.90
pluralizeTokenFunction · 0.90
indentLinesFunction · 0.90
warnMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected