Add comprehensive test coverage#58
Open
Pearce-Ropion wants to merge 4 commits into
Open
Conversation
Covers deepEqual, polyfillRequestAnimationFrame, validateConfigId, the default client singleton, and an end-to-end expansion of the initialize() client tests (URL parsing, config/elements/style APIs, event handlers, promise resolution and rejection, unsubscribers, and destroy behavior). React-dependent modules are intentionally left untested since react is only an optional peer dep and is not installed in the test environment.
peternandersson
approved these changes
May 11, 2026
| messageListener = listener as (event: unknown) => void; | ||
| } | ||
| return original(type, listener, options); | ||
| }) as typeof window.addEventListener); |
| result: { sigmaEnv: 'author', config: { foo: 'bar' } }, | ||
| error: null, | ||
| }); | ||
| await Promise.resolve(); |
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.
This PR significantly expands the test suite for the plugin client, replacing minimal lifecycle tests with comprehensive coverage of all client APIs and functionality.
Summary
The test suite for
initialize()has been completely rewritten to provide thorough coverage of the plugin client's behavior, including lifecycle management, configuration API, elements API, style API, and message handling. Additionally, new test files have been added for utility functions and the client singleton export.Notable Implementation Details
vi.spyOn()for mocking window methods and tracking postMessage callssendWindowMessage,postMessages,findPostMessage) abstract common test patternsbeforeEach/afterEachhooks to restore window state between testshttps://claude.ai/code/session_01HwKQWfqXUq4BBKom4bADuq