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

Function runTelemetryTest

tests/e2e/telemetry.test.ts:161–234  ·  view source on GitHub ↗
(
    killFn: (ctx: TestContext) => void,
    spawnOptions?: SpawnOptions,
  )

Source from the content-addressed store, hash-verified

159
160describe('Telemetry E2E', () => {
161 async function runTelemetryTest(
162 killFn: (ctx: TestContext) => void,
163 spawnOptions?: SpawnOptions,
164 ): Promise<void> {
165 const mockContext = await startMockServer();
166 const ctx: TestContext = {
167 mockServer: mockContext,
168 };
169
170 try {
171 ctx.process = spawn(
172 process.execPath,
173 [
174 SERVER_PATH,
175 '--usage-statistics',
176 '--headless',
177 `--clearcutEndpoint=http://127.0.0.1:${mockContext.port}`,
178 '--clearcutForceFlushIntervalMs=10',
179 '--clearcutIncludePidHeader',
180 ],
181 {
182 stdio: ['pipe', 'pipe', 'pipe'],
183 env: {
184 ...process.env,
185 CI: undefined,
186 CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS: undefined,
187 },
188 ...spawnOptions,
189 },
190 );
191
192 const startEvent = await Promise.race([
193 mockContext.waitForEvent(e => e.server_start !== undefined),
194 new Promise((_, reject) =>
195 setTimeout(
196 () => reject(new Error('Timeout waiting for server_start')),
197 10000,
198 ),
199 ),
200 ]);
201 assert.ok(startEvent, 'server_start event not received');
202
203 // Now that we received an event, we should have the Watchdog PID
204 const watchdogPid = mockContext.watchdogPid;
205 assert.ok(watchdogPid, 'Watchdog PID not captured from headers');
206
207 // Assert Watchdog is actually running
208 assert.strictEqual(
209 isProcessAlive(watchdogPid),
210 true,
211 'Watchdog process should be running',
212 );
213
214 // Trigger shutdown
215 killFn(ctx);
216
217 // Verify shutdown event
218 const shutdownEvent = await Promise.race([

Callers 1

telemetry.test.tsFile · 0.85

Calls 5

startMockServerFunction · 0.85
rejectFunction · 0.85
isProcessAliveFunction · 0.85
waitForProcessExitFunction · 0.85
cleanupTestFunction · 0.85

Tested by

no test coverage detected