MCPcopy Index your code
hub / github.com/code-pushup/cli / createRunnerFunction

Function createRunnerFunction

packages/plugin-axe/src/lib/runner/runner.ts:15–58  ·  view source on GitHub ↗
(
  urls: string[],
  ruleIds: string[],
  timeout: number,
  setupScript?: string,
)

Source from the content-addressed store, hash-verified

13
14/** Creates a runner function that executes Axe accessibility audits for given URLs. */
15export function createRunnerFunction(
16 urls: string[],
17 ruleIds: string[],
18 timeout: number,
19 setupScript?: string,
20): RunnerFunction {
21 return async (): Promise<AuditOutputs> => {
22 const runner = new AxeRunner();
23 const urlsCount = urls.length;
24
25 logger.info(
26 `Running Axe accessibility checks for ${pluralizeToken('URL', urlsCount)} ...`,
27 );
28
29 try {
30 if (setupScript) {
31 const setupFn = await loadSetupScript(setupScript);
32 await runner.captureAuthState(setupFn, timeout);
33 }
34
35 const results = await asyncSequential(
36 urls,
37 async (url, urlIndex): Promise<AxeUrlResult | null> =>
38 runForUrl(runner, { urlsCount, ruleIds, timeout, url, urlIndex }),
39 );
40
41 const collectedResults = results.filter(res => res != null);
42 const auditOutputs = collectedResults.flatMap(res => res.auditOutputs);
43 if (collectedResults.length === 0) {
44 throw new Error(
45 shouldExpandForUrls(urlsCount)
46 ? 'Axe failed to produce results for all URLs.'
47 : 'Axe did not produce any results.',
48 );
49 }
50
51 logResultsForAllUrls(collectedResults);
52
53 return auditOutputs;
54 } finally {
55 await runner.close();
56 }
57 };
58}
59
60async function runForUrl(
61 runner: AxeRunner,

Callers

nothing calls this directly

Calls 9

captureAuthStateMethod · 0.95
closeMethod · 0.95
pluralizeTokenFunction · 0.90
asyncSequentialFunction · 0.90
shouldExpandForUrlsFunction · 0.90
loadSetupScriptFunction · 0.85
runForUrlFunction · 0.85
infoMethod · 0.80
logResultsForAllUrlsFunction · 0.70

Tested by

no test coverage detected