Skip to content

chore: refactor plugin internals, add unit tests, update readme, add license#1

Merged
Lojhan merged 4 commits intomainfrom
chore/session-improvements
Mar 31, 2026
Merged

chore: refactor plugin internals, add unit tests, update readme, add license#1
Lojhan merged 4 commits intomainfrom
chore/session-improvements

Conversation

@Lojhan
Copy link
Copy Markdown
Collaborator

@Lojhan Lojhan commented Mar 31, 2026

Summary

Plugin refactor

  • Extracted pure helper functions from src/plugin.ts (getRuntimeSupport, canHandleRuntime, buildRunnerCommand, normalizeMetricsOptions, captureEnvSnapshot, applyEnvironmentOptions, restoreEnvironmentOptions, createMetricsSummary, selectTopSlowestMetrics, printMetricsSummary)
  • Added __internal export to expose helpers for unit testing without exposing them as public API

Unit tests

  • Added tests/plugin-internals.test.ts with 13 unit tests covering all extracted helpers
  • Tests cover: runner command injection (node/bun/deno), env lifecycle, metrics normalization, component name resolution, and DOM setup path resolution

README

  • Rewritten to match the shared-resources style
  • Added centered logo header with star CTA
  • Added runtime x DOM adapter compatibility matrix (Node >=20 / Bun >=1 / Deno >=2 x happy-dom / jsdom / custom)
  • Added NOTE callout explaining Deno + jsdom instability

Other

  • Added ISC LICENSE file
  • Scoped test:deno to happy-dom only (jsdom is unstable under Deno's npm compat layer)

Lojhan added 4 commits March 31, 2026 10:48
…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.
@Lojhan Lojhan enabled auto-merge (squash) March 31, 2026 14:10
@Lojhan Lojhan disabled auto-merge March 31, 2026 14:10
@Lojhan Lojhan merged commit 3695f93 into main Mar 31, 2026
10 checks passed
@Lojhan Lojhan deleted the chore/session-improvements branch March 31, 2026 14:11
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