Agent Skills › ChromeDevTools/devtools-frontend › devtools-testing-guidance

devtools-testing-guidance

GitHub

提供 Chrome DevTools 中编写新测试时选择合适测试套件(Unit、API 或 E2E)的指导。明确各类测试的适用场景、文件位置及构建配置,帮助开发者正确隔离和集成验证逻辑。

.agents/skills/devtools-testing-guidance/SKILL.md ChromeDevTools/devtools-frontend

Trigger Scenarios

需要为 Chrome DevTools 新功能编写单元测试 需要验证涉及 CDP 协议的业务逻辑集成测试 需要模拟完整用户旅程进行端到端测试

Install

npx skills add ChromeDevTools/devtools-frontend --skill devtools-testing-guidance -g -y
More Options

Non-standard path

npx skills add https://github.com/ChromeDevTools/devtools-frontend/tree/main/.agents/skills/devtools-testing-guidance -g -y

Use without installing

npx skills use ChromeDevTools/devtools-frontend@devtools-testing-guidance

指定 Agent (Claude Code)

npx skills add ChromeDevTools/devtools-frontend --skill devtools-testing-guidance -a claude-code -g -y

安装 repo 全部 skill

npx skills add ChromeDevTools/devtools-frontend --all -g -y

预览 repo 内 skill

npx skills add ChromeDevTools/devtools-frontend --list

SKILL.md

Frontmatter
{
    "name": "devtools-testing-guidance",
    "description": "Guidance on selecting the appropriate test suite (Unit, API, or E2E tests) when writing new tests in Chrome DevTools. MUST be used when writing new tests."
}

Testing Guidance

This guide outlines when and how to select the appropriate test suite when writing new tests in Chrome DevTools.

[!NOTE] This skill provides guidance on which test suite to choose when writing tests. To learn how to run tests, build targets, or execute linters, refer to the devtools-verification skill.

Choosing a Test Suite

1. Unit Tests

Default choice: The vast majority of tests in DevTools should be unit tests.

Use unit tests for isolated testing of individual functions, classes, models, helpers, and UI components.

  • Utilities & Framework:
    • Use TestUniverse (and foundation test helpers) for easy, isolated setup of required dependencies and models.
    • For testing UI widgets, use stubbed view functions and screenshot assertions rather than spinning up heavy DOM/browser infrastructure.
  • Location: Co-located next to their implementation files (e.g. TimelinePanel.ts and TimelinePanel.test.ts).
  • Test functions: import describe, it, beforeEach, etc. from mocha (e.g. import {describe, it} from 'mocha';). They are not available as globals.
  • BUILD.gn: test file should be added to devtools_ui_module("unittests") or devtools_foundation_module("foundation_unittests") target in the corresponding BUILD.gn file.

2. API Tests

Use API tests for integration tests that verify business logic requiring more complex setups or extensive CDP (Chrome DevTools Protocol) traffic, without needing the full DevTools frontend UI.

  • When to use:
    • Evaluating JavaScript expressions in the target page (e.g. via Runtime.evaluate).
    • Complex source map setups and symbolization.
    • Multi-context or target setups (workers, iframes, OOPIFs).
    • Tests that require extensive CDP mock setup.
    • Verifying the "foundational layer" of DevTools models against a real browser/web page.
  • Location: Defined in front_end/ with .test.api.ts extension (e.g. Universe.test.api.ts).
  • Test functions: import describe, it and setup from test/api/mocha-interface.ts. They are not available as globals.
  • BUILD.gn: test file should be added to devtools_api_test_module("api_tests") target in the corresponding BUILD.gn file, which needs test/api in its ts_deps.

3. End-to-End (E2E) Tests

Use E2E tests to verify real end-to-end user stories and user journeys.

  • When to use:
    • Verifying full user journeys across DevTools panels and drawers.
    • Complex UI behaviors that require extensive user interaction setup and benefit from a complete DevTools frontend page connected to an inspected target page over CDP.
  • Location: Defined in test/e2e/ (e.g. test/e2e/console/console-log.test.ts).
  • Test functions: import describe, it and setup from test/e2e/conductor/mocha-interface.ts (e.g. import {describe, it} from '../conductor/mocha-interface.js';). They are not available as globals.
  • BUILD.gn: test file should be added to the node_ts_library target in the corresponding BUILD.gn file, which needs "../conductor:implementation" in its ts_deps. And node_ts_library in test/e2e/BUILD.gn for its dependencies.

Version History

  • 6527f72 Current 2026-10-20 02:26

    移除了 Mocha 的全局声明,要求所有测试显式导入测试接口函数,并将缺失导入设为编译错误,以增强类型安全和代码规范性。

  • 678d19c 2026-08-20 15:20

Same Skill Collection

.agents/skills/code-review/SKILL.md
.agents/skills/devtools-ci/SKILL.md
.agents/skills/devtools-imports/SKILL.md
.agents/skills/devtools-model-management/SKILL.md
.agents/skills/devtools-setting-migration/SKILL.md
.agents/skills/devtools-source-maps/SKILL.md
.agents/skills/devtools-unicode-escaping/SKILL.md
.agents/skills/devtools-ux-writing-refactor/SKILL.md
.agents/skills/devtools-verification/SKILL.md
.agents/skills/evaluate-ai-css-completion/SKILL.md
.agents/skills/fix-tests/SKILL.md
.agents/skills/fixing-skipped-tests/SKILL.md
.agents/skills/foundation-test-migration/SKILL.md
.agents/skills/gerrit-cli/SKILL.md
.agents/skills/merging-devtools-module/SKILL.md
.agents/skills/migrate-chromium-test/SKILL.md
.agents/skills/review-models-core/SKILL.md
.agents/skills/review-tests/SKILL.md
.agents/skills/review-ui-widgets/SKILL.md
.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md
.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md
.agents/skills/ui-eng-vision-orchestrator/SKILL.md
.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md
.agents/skills/ui-eng-vision-widget-promoter/SKILL.md
.agents/skills/ui-widgets/SKILL.md
.agents/skills/version-control/SKILL.md
.agents/skills/repro-flaky-tests/SKILL.md

Metadata

Files
0
Version
6527f72
Hash
5341bb35
Indexed
2026-08-20 15:20

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-23 01:46
浙ICP备14020137号-1