jsdom

JavaScript implementation of the DOM and HTML standards for Node.js. jsdom provides a virtual browser environment — window, document, localStorage, fetch, CSS, events — without a headless browser. Powers Jest's default test environment (jsdom), enabling React/Vue/Angular component testing without a real browser. Also used for server-side rendering without Puppeteer/Playwright.

Evaluated Mar 06, 2026 (0d ago) v24.x / 25.x
Homepage ↗ Repo ↗ Developer Tools dom html browser-api testing node jest virtual-dom browser-emulation
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
95
/ 100
Is it safe for agents?
⚡ Reliability
87
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
82
Error Messages
78
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
85
Secret Handling
85

Script execution (runScripts: 'dangerously') is a security risk with untrusted HTML — only enable for trusted content. Default runScripts: 'outside-only' is safe for testing.

⚡ Reliability

Uptime/SLA
100
Version Stability
85
Breaking Changes
80
Error Recovery
82
AF Security Reliability

Best When

Running fast component tests in Jest without launching a browser — jsdom provides browser API coverage sufficient for most component testing.

Avoid When

You need pixel-accurate rendering, CSS layout, or JS execution fidelity of a real browser — use Playwright or Puppeteer.

Use Cases

  • Run React, Vue, and Angular component tests in Node.js using Jest's jsdom environment without launching a browser
  • Test DOM manipulation code in agent web application unit tests where speed matters over full browser fidelity
  • Parse and manipulate HTML documents in agent server-side workflows where full browser APIs (querySelector, addEventListener) are needed beyond Cheerio
  • Prototype server-side rendering without launching headless Chrome — jsdom renders HTML with CSS and JavaScript evaluation
  • Test agent web scraping code with a controllable DOM environment that can be seeded with specific HTML content

Not For

  • Production browser automation — jsdom is for testing; use Playwright or Puppeteer for production browser interactions
  • Pixel-accurate rendering — jsdom doesn't support CSS layout or painting; use headless Chrome for visual testing
  • JavaScript-heavy SPAs in production — jsdom may not execute all JS frameworks correctly; Playwright/Puppeteer with real Chromium is more reliable

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — local DOM emulation library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

jsdom is open source and free.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • jsdom doesn't implement CSS layout — getComputedStyle() and getBoundingClientRect() return zeros; use Playwright for layout-dependent tests
  • Some Web APIs are not implemented — ResizeObserver, IntersectionObserver, Web Workers, WebGL, Canvas are stubs; test code using these APIs requires Playwright
  • jsdom executes scripts by default when runScripts: 'dangerously' is set — only use with trusted HTML; arbitrary script execution is a security risk
  • Jest uses jsdom as its default testEnvironment — but Jest 27+ requires @jest-environment-jsdom separately; install it explicitly if moving from Jest 26
  • fetch() in jsdom requires Node.js 18+ or a fetch polyfill — add jest.config.js testEnvironmentOptions with fetch enabled or install node-fetch for older Node.js
  • Memory leaks in jsdom from event listeners on document/window — always call window.close() after tests to release jsdom resources in manual JSDOM() usage

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for jsdom.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5616
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered