qmetrics.net

jsdom

Node.js implementation of web DOM and HTML standards

jsdom emulates browser DOM and HTML APIs in Node.js for testing and scraping real web apps. The JSDOM constructor parses HTML and exposes a window object with configurable behavior.

Overview

jsdom is a JavaScript implementation of many web standards—chiefly the WHATWG DOM and HTML—for Node.js. The stated goal is to emulate enough of a browser subset to be useful when testing or scraping applications that expect a DOM.

The main entry point is the JSDOM class: pass HTML (or load from URL or file) and receive a document with window, standard DOM APIs, and options for URL, referrer, storage quotas, and parser location metadata. By default it parses like a browser, including implied html, head, and body structure.

Script execution inside parsed pages is optional and off by default because embedded scripts can reach the Node.js host if enabled with runScripts set to dangerously. Separate modes allow outside-only script globals or loading external scripts when resource loading is configured. jsdom can fetch subresources (frames, stylesheets, scripts, images with optional canvas) when resources are set to usable.

The environment behaves as headless by default (document.hidden true) unless pretendToBeVisual is set. Virtual consoles forward or capture page and implementation logs. Custom resource loaders, user agents, and request interceptors support controlled fetching for tests.

Key features

  • WHATWG DOM and HTML in Node.js
  • JSDOM constructor with window API
  • Optional in-page script execution
  • Configurable URL and referrer
  • Subresource loading options
  • Virtual console forwarding
  • fromURL and fromFile helpers
  • Headless default with visual pretend mode

Use cases

  • Unit tests for browser-oriented code
  • Server-side HTML parsing
  • Scraping with DOM APIs
  • Simulating pages without a browser
  • Controlled script execution in tests

Tags

Similar software

Puppeteer

JavaScript library for automating Chrome and Firefox

Puppeteer exposes a high-level JavaScript API to drive Chrome or Firefox through the DevTools Protocol or WebDriver BiDi. It defaults to headless browser control for scripts and tests.

★ 95.9k⟳ yesterdayApache-2.0

chromedp

Go library for Chrome DevTools Protocol browser control

chromedp drives Chrome and compatible browsers from Go via the DevTools Protocol without an external WebDriver. It starts browsers over a pipe by default and supports headless or visible automation.

★ 13.4k⟳ 10 days agoMIT

Playwright Go

Go library for cross-browser Chromium, Firefox, and WebKit automation

Playwright for Go drives Chromium, Firefox, and WebKit through one API for scraping, testing, and browser workflows. Headless and headed modes are supported on Linux, macOS, and Windows.

★ 3.5k⟳ 22 days agoMIT

Panther

PHP browser testing and web scraping library

Symfony Panther drives real Chrome or Firefox browsers via WebDriver for end-to-end tests and website scraping in PHP applications.

★ 3.1k⟳ 1 month agoMIT

Puppeteer Puppeteer

Node.js API for headless Chrome and Firefox automation

Puppeteer is a JavaScript library that automates Chrome and Firefox via Chrome DevTools Protocol and WebDriver BiDi. Use it for UI testing, PDFs, screenshots, and scripted browsing.

★ 2.4k⟳ yesterdayApache-2.0

Browserless

Headless Chrome driver layer on Puppeteer for Node.js

Browserless wraps Puppeteer to drive headless Chrome or Chromium from Node.js. It adds helpers for HTML, text, PDF, and screenshots with retries, ad blocking, and CLI access.

★ 1.8k⟳ yesterdayMIT