( scenarioPath: string, apiKey: string, server: TestServer, modelId: string, debug: boolean, includeSkill: boolean, extraServerArgs: string[] = [], )
| 35 | } |
| 36 | |
| 37 | async function runSingleScenario( |
| 38 | scenarioPath: string, |
| 39 | apiKey: string, |
| 40 | server: TestServer, |
| 41 | modelId: string, |
| 42 | debug: boolean, |
| 43 | includeSkill: boolean, |
| 44 | extraServerArgs: string[] = [], |
| 45 | ): Promise<void> { |
| 46 | const debugLog = (...args: unknown[]) => { |
| 47 | if (debug) { |
| 48 | console.log(...args); |
| 49 | } |
| 50 | }; |
| 51 | const absolutePath = path.resolve(scenarioPath); |
| 52 | debugLog( |
| 53 | `\n### Running Scenario: ${path.relative(ROOT_DIR, absolutePath)} ###`, |
| 54 | ); |
| 55 | |
| 56 | let client: Client | undefined; |
| 57 | let transport: StdioClientTransport | undefined; |
| 58 | |
| 59 | try { |
| 60 | const loadedScenario = await loadScenario(absolutePath); |
| 61 | const scenario = {...loadedScenario}; |
| 62 | |
| 63 | // Prepend skill content if requested |
| 64 | if (includeSkill) { |
| 65 | if (!fs.existsSync(SKILL_PATH)) { |
| 66 | throw new Error( |
| 67 | `Skill file not found at ${SKILL_PATH}. Please ensure the skill file exists.`, |
| 68 | ); |
| 69 | } |
| 70 | const skillContent = fs.readFileSync(SKILL_PATH, 'utf-8'); |
| 71 | scenario.prompt = `${skillContent}\n\n---\n\n${scenario.prompt}`; |
| 72 | } |
| 73 | |
| 74 | // Append random queryid to avoid caching issues and test distinct runs |
| 75 | const randomId = Math.floor(Math.random() * 1000000); |
| 76 | scenario.prompt = `${scenario.prompt}\nqueryid=${randomId}`; |
| 77 | |
| 78 | if (scenario.htmlRoute) { |
| 79 | server.addHtmlRoute( |
| 80 | scenario.htmlRoute.path, |
| 81 | scenario.htmlRoute.htmlContent, |
| 82 | ); |
| 83 | scenario.prompt = scenario.prompt.replace( |
| 84 | '<TEST_URL>', |
| 85 | server.getRoute(scenario.htmlRoute.path), |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | // Path to the compiled MCP server |
| 90 | const serverPath = path.join( |
| 91 | ROOT_DIR, |
| 92 | 'build/src/bin/chrome-devtools-mcp.js', |
| 93 | ); |
| 94 | if (!fs.existsSync(serverPath)) { |
no test coverage detected