Skip to content

perf(javascript): switch test environment from jsdom to happy-dom#847

Open
austingreco wants to merge 1 commit intomainfrom
agreco/switch-to-happy-dom
Open

perf(javascript): switch test environment from jsdom to happy-dom#847
austingreco wants to merge 1 commit intomainfrom
agreco/switch-to-happy-dom

Conversation

@austingreco
Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

What changed?

  • Replaced jsdom with happy-dom as the test DOM environment in vitest config
  • Updated one test assertion that relied on jsdom's CSS color normalization (rgb(255, 0, 0)red)
  • Updated ResizeObserver mock comment (happy-dom provides it natively, but we keep the mock to prevent real observation side effects)

Why?
happy-dom is a lighter-weight DOM implementation that provides faster test execution. Local benchmarks:

Metric jsdom happy-dom Change
Total duration 31.46s 27.57s -12%
Table integration tests 31.19s 23.30s -25%
Test execution time 51.03s 44.82s -12%

CI environments (slower hardware) tend to amplify these differences further.

How did you test it?

  • Ran full test suite locally: 865 tests, 105 files, all passing
  • yarn vitest --run

Potential risks

  • happy-dom has minor behavioral differences from jsdom (e.g., doesn't normalize CSS color values to rgb). One test was updated to account for this. Other tests may surface similar minor differences if they rely on jsdom-specific behavior.

Release notes

  • N/A (test infrastructure only, no user-facing changes)

Documentation Changes

  • N/A

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 20, 2026

📊 Combined Coverage Report

Component Coverage Baseline New Code Status
🐍 Python 81.81% ≥70% ≥90% ✅
🐹 Go 63.6% ≥60% ≥90% ✅
📜 JavaScript N/A% (no coverage data) ≥78.74% ≥90% ✅ ⏭️

Coverage Policy

Baseline (Existing Code):

  • Python: ≥70% (current coverage)
  • Go: ≥60% (current coverage)
  • JavaScript: ≥78.74% (current coverage)

New/Changed Code: ≥90% STRICTLY ENFORCED

Long-term Goal: Maintain and improve coverage baselines


📝 Coverage Guidelines
  • All new code must include tests
  • Coverage should not decrease from the base branch
  • Use # pragma: no cover sparingly for truly untestable code
  • Aim for meaningful tests, not just coverage numbers
🔗 Quick Links

happy-dom is a lighter-weight DOM implementation that provides faster
test execution. Local benchmarks show ~12% faster total duration and
~25% faster table integration tests.
@austingreco austingreco force-pushed the agreco/switch-to-happy-dom branch from 8d14500 to c6833b0 Compare February 20, 2026 20:06
@github-actions
Copy link
Copy Markdown

JavaScript Coverage Report

Total Coverage: 79.18%

Coverage Policy:

  • Baseline (existing code): ≥78.74% (current coverage)
  • New/changed code: ≥90% ✅ STRICTLY ENFORCED
Coverage Details
$(cat coverage/coverage-summary.json 2>/dev/null | node -p "const c=require('fs').readFileSync(0,'utf8'); JSON.stringify(JSON.parse(c).total, null, 2)" || echo "Coverage summary not available")

View detailed HTML report in artifacts

@craigmarker
Copy link
Copy Markdown
Contributor

How are you weighing the cons of adopting the happy-dom environment? My concern is primarily about less realistic/less established. What do you thiink?

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 24, 2026

CLA assistant check
All committers have signed the CLA.

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.

3 participants