Repository navigation
test: migrate memory tests off withMcpContext - #2729
Conversation
Migrate fixture-based heap snapshot tests off withMcpContext to avoid unnecessary browser launches: - Relocate fixture-based formatting tests to HeapSnapshotFormatter tests using HeapSnapshotManager directly. - Convert tool handler tests in memory tests to mock unit tests verifying parameter validation and delegation using createHandlerMocks(). - Retain take_heapsnapshot as an e2e test with withMcpContext. - Relocate snapshot comparison caching test to HeapSnapshotManager tests.
|
Hi @OrKoN, This PR implements the split we discussed for migrating memory tests off
All tests pass cleanly and formatting checks are green. Could you please take a look when you have a moment? Thanks! |
OrKoN
left a comment
There was a problem hiding this comment.
Let's also add the following impovements:
- Restore dropped error handling & lifecycle tests in HeapSnapshotManager.test.ts:
• Add tests for getNodesById() throwing on non-existent class ID.
• Add tests for getDetailedClassDiff() throwing on invalid classIndex.
• Add tests for disposeSnapshot() and getStats() / getStaticData(). - Add unit tests for heap snapshot formatting in tests/McpResponse.test.ts:
Test response.setHeapSnapshot*() and response.handle() with mock data in tests/McpResponse.test.ts to ensure coverage for headers, stats formatting, pagination summaries, and node sorting. - Complete tool handler test cases in tests/tools/memory.test.ts:
Add the missing default and paginated parameter test cases for get_heapsnapshot_retainers, get_heapsnapshot_duplicate_strings, get_heapsnapshot_retaining_paths, and unit test take_heapsnapshot.
|
@OrKoN Thanks for the review! I've added all requested improvements in the latest commit:
All tests and format checks are passing cleanly. |
- Restore dropped error handling and lifecycle tests in HeapSnapshotManager.test.ts - Add unit tests for heap snapshot formatting in tests/McpResponse.test.ts - Complete tool handler test cases for get_heapsnapshot_* and take_heapsnapshot in tests/tools/memory.test.ts
cf05741 to
904f19d
Compare
|
Thanks for the approval, @OrKoN! It looks like the CI run failed only on Could you please re-run the failed check when you have a moment? Thanks! |
|
Hi @OrKoN, |
|
Let's migrate https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/main/tests/tools/network.test.ts next while ensuring that we maintain/move the e2e coverage to the network collector tests. |
Description
This PR migrates fixture-based heap snapshot tests off
withMcpContextto avoid launching and closing headless Chromium unnecessarily:tests/tools/memory.test.tstotests/formatters/HeapSnapshotFormatter.test.tsusingHeapSnapshotManagerdirectly (exercises genuine.heapsnapshotfixtures in Node without browser overhead).tests/tools/memory.test.tsto mock-based unit tests usingcreateHandlerMocks()to verify parameter validation, default handling, and method delegation tocontextandresponse.take_heapsnapshotas a real-browser e2e test withwithMcpContext(genuinely requires live CDPcaptureHeapSnapshoton a real page).tests/processors/HeapSnapshotManager.test.ts.tests/mocks.ts.Test Plan
npm run buildnode scripts/test.js tests/processors/HeapSnapshotManager.test.tsnode scripts/test.js tests/formatters/HeapSnapshotFormatter.test.tsnode scripts/test.js tests/tools/memory.test.tsnpm run check-formatnpm run docs:generate