chore: refactor plugin internals, add unit tests, update readme, add license#1
Merged
chore: refactor plugin internals, add unit tests, update readme, add license#1
Conversation
…license - Extract pure helper functions from src/plugin.ts for testability - Add __internal export to expose helpers for unit tests - Add tests/plugin-internals.test.ts with 13 unit tests covering all helpers - Update README to match shared-resources style with compatibility matrix - Scope test:deno to happy-dom only (jsdom unstable under Deno) - Add ISC LICENSE file
…eno v2 - Replace ISC with MIT in LICENSE, package.json, and README - Wrap GlobalRegistrator's dispatchEvent in dom-setup-happy.ts to silently drop native Deno events that fail happy-dom's instanceof check (Deno v2 dispatches a built-in load event after module init)
…n under Deno v2
happy-dom's GlobalRegistrator replaces both globalThis.Event and
globalThis.dispatchEvent. Deno v2 calls dispatchLoadEvent after each
module finishes loading, which does: globalThis.dispatchEvent(new Event('load')).
- If only dispatchEvent is restored, new Event('load') returns a
happy-dom Event that lacks Deno's internal symbol properties, causing
TypeError: Cannot set properties of undefined (setting 'target')
- Snapshot both Event and dispatchEvent before GlobalRegistrator.register()
and restore both afterwards; React and @testing-library/dom dispatch
events through element.dispatchEvent(), never through globalThis.
Also updates ci_compatibility-deno.yml to use denoland/setup-deno@v2.
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.
Summary
Plugin refactor
src/plugin.ts(getRuntimeSupport,canHandleRuntime,buildRunnerCommand,normalizeMetricsOptions,captureEnvSnapshot,applyEnvironmentOptions,restoreEnvironmentOptions,createMetricsSummary,selectTopSlowestMetrics,printMetricsSummary)__internalexport to expose helpers for unit testing without exposing them as public APIUnit tests
tests/plugin-internals.test.tswith 13 unit tests covering all extracted helpersREADME
Other
test:denoto happy-dom only (jsdom is unstable under Deno's npm compat layer)