chromedevtools--chrome-devtools-mcp
ef61a08707
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/165 This PR uses page_resize logic to set the initial viewport size. Not using the emulation because it looks buggy in headful which is our default mode.
79 行
1.8 KiB
TypeScript
79 行
1.8 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
import assert from 'node:assert';
|
|
import {describe, it} from 'node:test';
|
|
|
|
import {parseArguments} from '../src/cli.js';
|
|
|
|
describe('cli args parsing', () => {
|
|
it('parses with default args', async () => {
|
|
const args = parseArguments('1.0.0', ['node', 'main.js']);
|
|
assert.deepStrictEqual(args, {
|
|
_: [],
|
|
headless: false,
|
|
isolated: false,
|
|
$0: 'npx chrome-devtools-mcp@latest',
|
|
channel: 'stable',
|
|
});
|
|
});
|
|
|
|
it('parses with browser url', async () => {
|
|
const args = parseArguments('1.0.0', [
|
|
'node',
|
|
'main.js',
|
|
'--browserUrl',
|
|
'http://localhost:3000',
|
|
]);
|
|
assert.deepStrictEqual(args, {
|
|
_: [],
|
|
headless: false,
|
|
isolated: false,
|
|
$0: 'npx chrome-devtools-mcp@latest',
|
|
'browser-url': 'http://localhost:3000',
|
|
browserUrl: 'http://localhost:3000',
|
|
u: 'http://localhost:3000',
|
|
});
|
|
});
|
|
|
|
it('parses with executable path', async () => {
|
|
const args = parseArguments('1.0.0', [
|
|
'node',
|
|
'main.js',
|
|
'--executablePath',
|
|
'/tmp/test 123/chrome',
|
|
]);
|
|
assert.deepStrictEqual(args, {
|
|
_: [],
|
|
headless: false,
|
|
isolated: false,
|
|
$0: 'npx chrome-devtools-mcp@latest',
|
|
'executable-path': '/tmp/test 123/chrome',
|
|
e: '/tmp/test 123/chrome',
|
|
executablePath: '/tmp/test 123/chrome',
|
|
});
|
|
});
|
|
|
|
it('parses viewport', async () => {
|
|
const args = parseArguments('1.0.0', [
|
|
'node',
|
|
'main.js',
|
|
'--viewport',
|
|
'888x777',
|
|
]);
|
|
assert.deepStrictEqual(args, {
|
|
_: [],
|
|
headless: false,
|
|
isolated: false,
|
|
$0: 'npx chrome-devtools-mcp@latest',
|
|
channel: 'stable',
|
|
viewport: {
|
|
width: 888,
|
|
height: 777,
|
|
},
|
|
});
|
|
});
|
|
});
|