Skip to content

Commit 47a50ca

Browse files
authored
chore: split cli tests (#1779)
splits cli test that might reach the test file timeout more often.
1 parent 73e1e24 commit 47a50ca

File tree

6 files changed

+258
-177
lines changed

6 files changed

+258
-177
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import assert from 'node:assert';
8+
import {describe, it, afterEach, beforeEach} from 'node:test';
9+
10+
import {
11+
assertDaemonIsNotRunning,
12+
assertDaemonIsRunning,
13+
runCli,
14+
} from '../utils.js';
15+
16+
describe('chrome-devtools', () => {
17+
beforeEach(async () => {
18+
await runCli(['stop']);
19+
await assertDaemonIsNotRunning();
20+
});
21+
22+
afterEach(async () => {
23+
await runCli(['stop']);
24+
await assertDaemonIsNotRunning();
25+
});
26+
27+
it('can invoke list_pages', async () => {
28+
await assertDaemonIsNotRunning();
29+
30+
const startResult = await runCli(['start']);
31+
assert.strictEqual(
32+
startResult.status,
33+
0,
34+
`start command failed: ${startResult.stderr}`,
35+
);
36+
37+
const listPagesResult = await runCli(['list_pages']);
38+
assert.strictEqual(
39+
listPagesResult.status,
40+
0,
41+
`list_pages command failed: ${listPagesResult.stderr}`,
42+
);
43+
assert(
44+
listPagesResult.stdout.includes('about:blank'),
45+
'list_pages output is unexpected',
46+
);
47+
48+
await assertDaemonIsRunning();
49+
});
50+
51+
it('can take screenshot', async () => {
52+
const startResult = await runCli(['start']);
53+
assert.strictEqual(
54+
startResult.status,
55+
0,
56+
`start command failed: ${startResult.stderr}`,
57+
);
58+
59+
const result = await runCli(['take_screenshot']);
60+
assert.strictEqual(
61+
result.status,
62+
0,
63+
`take_screenshot command failed: ${result.stderr}`,
64+
);
65+
assert(
66+
result.stdout.includes('.png'),
67+
'take_screenshot output is unexpected',
68+
);
69+
});
70+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import assert from 'node:assert';
8+
import {describe, it, afterEach, beforeEach} from 'node:test';
9+
10+
import {assertDaemonIsNotRunning, runCli} from '../utils.js';
11+
12+
describe('chrome-devtools', () => {
13+
beforeEach(async () => {
14+
await runCli(['stop']);
15+
await assertDaemonIsNotRunning();
16+
});
17+
18+
afterEach(async () => {
19+
await runCli(['stop']);
20+
await assertDaemonIsNotRunning();
21+
});
22+
23+
it('forwards disclaimers to stderr on start', async () => {
24+
const result = await runCli(['start']);
25+
assert.strictEqual(
26+
result.status,
27+
0,
28+
`start command failed: ${result.stderr}`,
29+
);
30+
assert(
31+
result.stderr.includes('chrome-devtools-mcp exposes content'),
32+
'Disclaimer not found in stderr on start',
33+
);
34+
});
35+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import assert from 'node:assert';
8+
import fs from 'node:fs';
9+
import os from 'node:os';
10+
import path from 'node:path';
11+
import {describe, it, afterEach, beforeEach} from 'node:test';
12+
13+
import {
14+
assertDaemonIsNotRunning,
15+
assertDaemonIsRunning,
16+
runCli,
17+
} from '../utils.js';
18+
19+
describe('chrome-devtools', () => {
20+
beforeEach(async () => {
21+
await runCli(['stop']);
22+
await assertDaemonIsNotRunning();
23+
});
24+
25+
afterEach(async () => {
26+
await runCli(['stop']);
27+
await assertDaemonIsNotRunning();
28+
});
29+
30+
it('can start and stop the daemon', async () => {
31+
await assertDaemonIsNotRunning();
32+
33+
const startResult = await runCli(['start']);
34+
assert.strictEqual(
35+
startResult.status,
36+
0,
37+
`start command failed: ${startResult.stderr}`,
38+
);
39+
40+
await assertDaemonIsRunning();
41+
42+
const stopResult = await runCli(['stop']);
43+
assert.strictEqual(
44+
stopResult.status,
45+
0,
46+
`stop command failed: ${stopResult.stderr}`,
47+
);
48+
49+
await assertDaemonIsNotRunning();
50+
});
51+
52+
it('can start the daemon with userDataDir', async () => {
53+
const userDataDir = path.join(
54+
os.tmpdir(),
55+
`chrome-devtools-test-${crypto.randomUUID()}`,
56+
);
57+
fs.mkdirSync(userDataDir, {recursive: true});
58+
59+
const startResult = await runCli(['start', '--userDataDir', userDataDir]);
60+
assert.strictEqual(
61+
startResult.status,
62+
0,
63+
`start command failed: ${startResult.stderr}`,
64+
);
65+
assert.ok(
66+
!startResult.stderr.includes(
67+
'Arguments userDataDir and isolated are mutually exclusive',
68+
),
69+
`unexpected conflict error: ${startResult.stderr}`,
70+
);
71+
72+
await assertDaemonIsRunning();
73+
});
74+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import assert from 'node:assert';
8+
import {describe, it, afterEach, beforeEach} from 'node:test';
9+
10+
import {
11+
assertDaemonIsNotRunning,
12+
assertDaemonIsRunning,
13+
runCli,
14+
} from '../utils.js';
15+
16+
describe('chrome-devtools', () => {
17+
beforeEach(async () => {
18+
await runCli(['stop']);
19+
await assertDaemonIsNotRunning();
20+
});
21+
22+
afterEach(async () => {
23+
await runCli(['stop']);
24+
await assertDaemonIsNotRunning();
25+
});
26+
27+
it('reports daemon status correctly', async () => {
28+
await assertDaemonIsNotRunning();
29+
30+
const startResult = await runCli(['start']);
31+
assert.strictEqual(
32+
startResult.status,
33+
0,
34+
`start command failed: ${startResult.stderr}`,
35+
);
36+
37+
await assertDaemonIsRunning();
38+
});
39+
});

tests/e2e/chrome-devtools.test.ts

Lines changed: 0 additions & 177 deletions
This file was deleted.

0 commit comments

Comments
 (0)