MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / withClient

Function withClient

tests/index.test.ts:28–61  ·  view source on GitHub ↗
(
    cb: (client: Client) => Promise<void>,
    extraArgs: string[] = [],
    options: {capabilities?: ClientCapabilities} = {},
  )

Source from the content-addressed store, hash-verified

26
27describe('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({

Callers 1

index.test.tsFile · 0.85

Calls 2

connectMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected