(
cb: (client: Client) => Promise<void>,
extraArgs: string[] = [],
options: {capabilities?: ClientCapabilities} = {},
)
| 26 | |
| 27 | describe('e2e', () => { |
| 28 | async function withClient( |
| 29 | cb: (client: Client) => Promise<void>, |
| 30 | extraArgs: string[] = [], |
| 31 | options: {capabilities?: ClientCapabilities} = {}, |
| 32 | ) { |
| 33 | const transport = new StdioClientTransport({ |
| 34 | command: 'node', |
| 35 | args: [ |
| 36 | 'build/src/bin/chrome-devtools-mcp.js', |
| 37 | '--headless', |
| 38 | '--isolated', |
| 39 | '--executable-path', |
| 40 | await executablePath(), |
| 41 | ...extraArgs, |
| 42 | ], |
| 43 | env: {...process.env, CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS: 'true'}, |
| 44 | }); |
| 45 | const client = new Client( |
| 46 | { |
| 47 | name: 'e2e-test', |
| 48 | version: '1.0.0', |
| 49 | }, |
| 50 | { |
| 51 | capabilities: options.capabilities ?? {}, |
| 52 | }, |
| 53 | ); |
| 54 | |
| 55 | try { |
| 56 | await client.connect(transport); |
| 57 | await cb(client); |
| 58 | } finally { |
| 59 | await client.close(); |
| 60 | } |
| 61 | } |
| 62 | it('calls a tool', async t => { |
| 63 | await withClient(async client => { |
| 64 | const result = await client.callTool({ |
no test coverage detected