test: migrate memory tests off withMcpContext - #2729
Open
maheshsingh20 wants to merge 1 commit into
Open
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.
Contributor
Author
|
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
reviewed
Sep 11, 2026
OrKoN
left a comment
Collaborator
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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