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

Function loadSetupScript

packages/plugin-axe/src/lib/runner/setup.ts:31–55  ·  view source on GitHub ↗
(
  setupScript: string,
)

Source from the content-addressed store, hash-verified

29
30/** Loads and validates a setup script module from the given path. */
31export async function loadSetupScript(
32 setupScript: string,
33): Promise<SetupFunction> {
34 const absolutePath = path.isAbsolute(setupScript)
35 ? setupScript
36 : path.join(process.cwd(), setupScript);
37
38 if (!(await fileExists(absolutePath))) {
39 throw new Error(`Setup script not found: ${absolutePath}`);
40 }
41
42 const validModule = await logger.task(
43 `Loading setup script from ${absolutePath}`,
44 async () => {
45 const url = pathToFileURL(absolutePath).toString();
46 const module: unknown = await import(url);
47 const validated = await validateAsync(setupScriptModuleSchema, module, {
48 filePath: absolutePath,
49 });
50 return { message: 'Setup script loaded successfully', result: validated };
51 },
52 );
53
54 return validModule.default;
55}
56
57/** Executes the setup function with the provided Playwright page. */
58export async function runSetup(

Callers 2

setup.int.test.tsFile · 0.85
createRunnerFunctionFunction · 0.85

Calls 4

fileExistsFunction · 0.90
validateAsyncFunction · 0.90
taskMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected