test: migrate emulation tests off withMcpContext to unit tests by maheshsingh20 · Pull Request #2665 · ChromeDevTools/chrome-devtools-mcp · GitHub
Skip to content

test: migrate emulation tests off withMcpContext to unit tests - #2665

Open
maheshsingh20 wants to merge 1 commit into
ChromeDevTools:mainfrom
maheshsingh20:test/finish-emulation-unit-tests
Open

test: migrate emulation tests off withMcpContext to unit tests#2665
maheshsingh20 wants to merge 1 commit into
ChromeDevTools:mainfrom
maheshsingh20:test/finish-emulation-unit-tests

Conversation

@maheshsingh20

@maheshsingh20 maheshsingh20 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Relates to #2639.

Follow-up to #2641 and feedback in #2660 (AGENTS.md).

Summary of Changes

  1. tests/tools/emulation.test.ts:

    • Completely migrated off withMcpContext, removing all real-browser launches, serverHooks, and HTTP fixtures.
    • All tool handler test suites (geolocation, viewport, userAgent, extraHttpHeaders, colorScheme, network, cpu) now use createHandlerMocks() from tests/mocks.ts and verify page.emulate() is invoked with exact expected arguments.
  2. tests/McpPage.test.ts:

    • Added unit test coverage for McpPage.emulate() using createMockPuppeteerPage():
      • Offline network throttling settings and network blocking guard.
      • Secondary DevTools session CPU throttling delegation.
      • Geolocation set/clear behavior.
      • Viewport set/clear with default parameter merging.
      • Extra HTTP headers set/clear behavior.

Verification

  • npm run check-format: Passed (clean ESLint + Prettier)
  • npm run build: Compiled with exit code 0
  • node scripts/test.js tests/tools/emulation.test.ts: 50/50 tests passed
  • node scripts/test.js tests/McpPage.test.ts: 32/32 tests passed

@maheshsingh20

maheshsingh20 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant