# jsdom

*noun*

say it: **“JAY-ESS-dom”** **/ˈdʒeɪ ɛs dɒm/**

A pretend browser page that runs inside Node, so tests can build a page, click its buttons and read its text without opening a browser.

## What is **jsdom** in JavaScript?

**jsdom** — A browser's page model, rebuilt in JavaScript so it runs inside Node. Tests use it to build a page, click a button with `dispatchEvent` and read text with `textContent`, without opening a browser. Vitest turns it on with the `jsdom` environment.

```javascript
// @vitest-environment jsdom
import { it, expect } from 'vitest';

it('shows the seats left', () => {
  document.body.innerHTML = '<p id="seats">Seats left: 3</p>';
  expect(document.querySelector('#seats').textContent).toBe('Seats left: 3');
});
```

## In a sentence

- “The test runs in **jsdom**, so it can click the Add to cart button and read the new total.”
- “I added the comment // @vitest-environment **jsdom** at the top of the test file so document worked.”

Level: Freelancer · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=4)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/jsdom
