chromedevtools--chrome-devtools-mcp
13a18e2380
The client is meant to start the daemon if it is not running or connect to the existing one. Long-running client connections are not needed yet. Removed previous direct daemon test as we better test it via the client, the intended way to manage the daemon.
50 行
1.5 KiB
TypeScript
50 行
1.5 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import assert from 'node:assert';
|
|
import {describe, it, afterEach} from 'node:test';
|
|
|
|
import {startDaemon, stopDaemon} from '../../src/daemon/client.js';
|
|
import {isDaemonRunning} from '../../src/daemon/utils.js';
|
|
|
|
describe('daemon client', () => {
|
|
afterEach(async () => {
|
|
if (isDaemonRunning()) {
|
|
await stopDaemon();
|
|
// Wait a bit for the daemon to fully terminate and clean up its files.
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
}
|
|
});
|
|
|
|
it('should start and stop daemon', async () => {
|
|
assert.ok(!isDaemonRunning(), 'Daemon should not be running initially');
|
|
|
|
await startDaemon();
|
|
assert.ok(isDaemonRunning(), 'Daemon should be running after start');
|
|
|
|
await stopDaemon();
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
assert.ok(!isDaemonRunning(), 'Daemon should not be running after stop');
|
|
});
|
|
|
|
it('should handle starting daemon when already running', async () => {
|
|
await startDaemon();
|
|
assert.ok(isDaemonRunning(), 'Daemon should be running');
|
|
|
|
// Starting again should be a no-op
|
|
await startDaemon();
|
|
assert.ok(isDaemonRunning(), 'Daemon should still be running');
|
|
});
|
|
|
|
it('should handle stopping daemon when not running', async () => {
|
|
assert.ok(!isDaemonRunning(), 'Daemon should not be running initially');
|
|
|
|
// Stopping when not running should be a no-op
|
|
await stopDaemon();
|
|
assert.ok(!isDaemonRunning(), 'Daemon should still not be running');
|
|
});
|
|
});
|