Skip to content

Chrome DevTools for coding agents

build: compile tests/ with GN ts_library and drop direct tsc calls (#3332)

Nikolay Vitkov9d2b1861df23
diff --git a/BUILD.gn b/BUILD.gn
index 2b60c583..5b69e71b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -5,12 +5,12 @@ group("default") {
deps = [
":devtools_deps",
"//src:all",
+ "//tests",
]
}
group("devtools_deps") {
public_deps = [
- "//src:all",
"//third_party/devtools-frontend/front_end/entrypoints/formatter_worker:worker_entrypoint",
"//third_party/devtools-frontend/front_end/entrypoints/heap_snapshot_worker:worker_entrypoint",
"//third_party/devtools-frontend/front_end/models/issues_manager:descriptions",
diff --git a/package.json b/package.json
index b08c43e1..dcf17da1 100644
--- a/package.json
+++ b/package.json
@@ -13,8 +13,8 @@
"clean": "node scripts/clean.ts",
"clean:submodules": "node scripts/clean-submodules.ts",
"bundle": "npm run clean && npm run build && rollup -c rollup.config.js",
- "build": "node scripts/ninja.ts devtools_deps && tsc",
- "typecheck": "node scripts/ninja.ts devtools_deps && tsc --noEmit",
+ "build": "node scripts/ninja.ts",
+ "typecheck": "node scripts/ninja.ts",
"format": "eslint --cache --fix . && prettier --write --cache .",
"check-format": "eslint --cache . && prettier --check --cache .",
"gen": "npm run build && npm run cli:generate && npm run docs:generate && npm run update-metrics && npm run format",
diff --git a/scripts/clean.ts b/scripts/clean.ts
index ebcce95b..f630a8c3 100644
--- a/scripts/clean.ts
+++ b/scripts/clean.ts
@@ -10,11 +10,7 @@ import {resolve} from 'node:path';
import {runGnGen} from './gn-gen.ts';
const projectRoot = process.cwd();
-const pathsToRemove = [
- 'out/Default/gen/src',
- 'out/Default/gen/tests',
- 'out/Default/gen/tsconfig.tsbuildinfo',
-];
+const pathsToRemove = ['out/Default/gen/src', 'out/Default/gen/tests'];
for (const relPath of pathsToRemove) {
rmSync(resolve(projectRoot, relPath), {recursive: true, force: true});
diff --git a/tests/BUILD.gn b/tests/BUILD.gn
new file mode 100644
index 00000000..51803b91
--- /dev/null
+++ b/tests/BUILD.gn
@@ -0,0 +1,124 @@
+# Copyright 2026 Google LLC
+# SPDX-License-Identifier: Apache-2.0
+
+import(
+ "//third_party/devtools-frontend/scripts/build/typescript/typescript.gni")
+
+ts_library("tests") {
+ runs_in = "node"
+
+ es_libs = [
+ "dom",
+ "dom.iterable",
+ "ESNext.Disposable",
+ ]
+
+ sources = [
+ "LogpointManager.test.ts",
+ "McpContext.test.ts",
+ "McpPage.test.ts",
+ "McpResponse.test.ts",
+ "McpServer.test.ts",
+ "McpWorker.test.ts",
+ "SlimMcpResponse.test.ts",
+ "TextSnapshot.test.ts",
+ "ToolHandler.test.ts",
+ "browser.test.ts",
+ "cli-imports.test.ts",
+ "cli.test.ts",
+ "collectors/PageCollector.test.ts",
+ "collectors/ServiceWorkerCollector.test.ts",
+ "config/ConfigLocator.test.ts",
+ "config/ConfigWatcher.test.ts",
+ "config/ServerConfig.test.ts",
+ "config/mcp-options.test.ts",
+ "daemon/client.test.ts",
+ "daemon/symlink.test.ts",
+ "daemon/utils.test.ts",
+ "devtools/DevToolsCommentBridge.test.ts",
+ "devtools/DevtoolsUtils.test.ts",
+ "e2e/chrome-devtools-commands.test.ts",
+ "e2e/chrome-devtools-disabled-tools.test.ts",
+ "e2e/chrome-devtools-disclaimers.test.ts",
+ "e2e/chrome-devtools-hyphen-positionals.test.ts",
+ "e2e/chrome-devtools-performance.test.ts",
+ "e2e/chrome-devtools-start-stop.test.ts",
+ "e2e/chrome-devtools-status.test.ts",
+ "e2e/telemetry.test.ts",
+ "formatters/CommentFormatter.test.ts",
+ "formatters/ConsoleFormatter.test.ts",
+ "formatters/ConsoleFormatterGrouping.test.ts",
+ "formatters/CssFormatter.test.ts",
+ "formatters/HeapSnapshotFormatter.test.ts",
+ "formatters/IssueFormatter.test.ts",
+ "formatters/LogpointFormatter.test.ts",
+ "formatters/NetworkFormatter.test.ts",
+ "formatters/RemoteObjectFormatter.test.ts",
+ "formatters/WebAuthnFormatter.test.ts",
+ "formatters/snapshotFormatter.test.ts",
+ "index.test.ts",
+ "mocks.ts",
+ "network_blocking.test.ts",
+ "processors/HeapSnapshotManager.test.ts",
+ "roots.test.ts",
+ "server.ts",
+ "setup.ts",
+ "setupDevTools.ts",
+ "shutdown.test.ts",
+ "snapshot.ts",
+ "telemetry/ClearcutLogger.test.ts",
+ "telemetry/WatchdogClient.test.ts",
+ "telemetry/flagUtils.test.ts",
+ "telemetry/metricsRegistry.test.ts",
+ "telemetry/persistence.test.ts",
+ "telemetry/transformation.test.ts",
+ "telemetry/watchdog/ClearcutSender.test.ts",
+ "third_party_notices.test.ts",
+ "tools/comments.test.ts",
+ "tools/console.test.ts",
+ "tools/css.test.ts",
+ "tools/emulation.test.ts",
+ "tools/extensions.test.ts",
+ "tools/input.test.ts",
+ "tools/lighthouse.test.ts",
+ "tools/logpoints.test.ts",
+ "tools/memory.test.ts",
+ "tools/network.test.ts",
+ "tools/pages.test.ts",
+ "tools/performance.test.ts",
+ "tools/pwa.test.ts",
+ "tools/screencast.test.ts",
+ "tools/screenshot.test.ts",
+ "tools/script.test.ts",
+ "tools/slim/tools.test.ts",
+ "tools/snapshot.test.ts",
+ "tools/thirdPartyDeveloper.test.ts",
+ "tools/tools.test.ts",
+ "tools/webauthn.test.ts",
+ "tools/webmcp.test.ts",
+ "trace-processing/ChunkedTraceParser.test.ts",
+ "trace-processing/fixtures/load.ts",
+ "trace-processing/parse.test.ts",
+ "utils.ts",
+ "utils/TaskRunner.test.ts",
+ "utils/WaitForHelper.test.ts",
+ "utils/bytes.test.ts",
+ "utils/check-for-updates.test.ts",
+ "utils/errorHandling.test.ts",
+ "utils/files.test.ts",
+ "utils/id.test.ts",
+ "utils/keyboard.test.ts",
+ "utils/logger.test.ts",
+ "utils/pagination.test.ts",
+ "utils/resourceType.test.ts",
+ "utils/text.test.ts",
+ "utils/timeout.test.ts",
+ "utils/url.test.ts",
+ ]
+
+ ts_deps = [
+ "//src:bin",
+ "//src:mcp_lib",
+ "//src:third_party",
+ ]
+}
diff --git a/tests/formatters/snapshotFormatter.test.ts b/tests/formatters/snapshotFormatter.test.ts
index 4c672d78..679a8de5 100644
--- a/tests/formatters/snapshotFormatter.test.ts
+++ b/tests/formatters/snapshotFormatter.test.ts
@@ -10,7 +10,7 @@ import {describe, it} from 'node:test';
import type {ElementHandle} from 'puppeteer-core';
import {SnapshotFormatter} from '../../src/formatters/SnapshotFormatter.js';
-import type {TextSnapshot} from '../../src/TextSnapshot.js';
+import {TextSnapshot} from '../../src/TextSnapshot.js';
import type {TextSnapshotNode} from '../../src/types.js';
describe('snapshotFormatter', () => {
@@ -390,16 +390,15 @@ describe('snapshotFormatter', () => {
},
};
- const formatter = new SnapshotFormatter({
- snapshotId: '1',
- root: node,
- idToNode: new Map(),
- hasSelectedElement: true,
- verbose: false,
- resolveCdpElementId() {
- return undefined;
- },
- });
+ const formatter = new SnapshotFormatter(
+ new TextSnapshot({
+ snapshotId: '1',
+ root: node,
+ idToNode: new Map(),
+ hasSelectedElement: true,
+ verbose: false,
+ }),
+ );
const formatted = formatter.toString();
t.assert.snapshot(formatted);
@@ -427,16 +426,15 @@ describe('snapshotFormatter', () => {
},
};
- const formatter = new SnapshotFormatter({
- snapshotId: '1',
- root: node,
- idToNode: new Map(),
- hasSelectedElement: true,
- verbose: true,
- resolveCdpElementId() {
- return undefined;
- },
- });
+ const formatter = new SnapshotFormatter(
+ new TextSnapshot({
+ snapshotId: '1',
+ root: node,
+ idToNode: new Map(),
+ hasSelectedElement: true,
+ verbose: true,
+ }),
+ );
const formatted = formatter.toString();
t.assert.snapshot(formatted);
@@ -464,17 +462,16 @@ describe('snapshotFormatter', () => {
},
};
- const formatter = new SnapshotFormatter({
- snapshotId: '1',
- root: node,
- idToNode: new Map(),
- hasSelectedElement: true,
- selectedElementUid: '1_1',
- verbose: false,
- resolveCdpElementId() {
- return '1_1';
- },
- });
+ const formatter = new SnapshotFormatter(
+ new TextSnapshot({
+ snapshotId: '1',
+ root: node,
+ idToNode: new Map(),
+ hasSelectedElement: true,
+ selectedElementUid: '1_1',
+ verbose: false,
+ }),
+ );
const formatted = formatter.toString();
t.assert.snapshot(formatted);