Gathering detailed insights and metrics for global-jsdom
Gathering detailed insights and metrics for global-jsdom
Gathering detailed insights and metrics for global-jsdom
Gathering detailed insights and metrics for global-jsdom
jsdom-global
Enable DOM in Node.js
@types/jsdom-global
TypeScript definitions for jsdom-global
jest-environment-jsdom-global
> Similar to the standard [`jest-environment-jsdom`](https://github.com/facebook/jest/tree/main/packages/jest-environment-jsdom), but exposes `jsdom` so that you can reconfigure it from your test suites.
@happy-dom/global-registrator
Use Happy DOM globally in a Node.js environment for testing.
npm install global-jsdom
Typescript
Module System
Min. Node Version
Node Version
NPM Version
90.6
Supply Chain
98.9
Quality
77.4
Maintenance
100
Vulnerability
98.9
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
76 Stars
302 Commits
10 Forks
2 Watchers
2 Branches
13 Contributors
Updated on Jun 01, 2025
Latest Version
26.0.0
Package Id
global-jsdom@26.0.0
Unpacked Size
9.33 kB
Size
3.30 kB
File Count
7
NPM Version
8.19.3
Node Version
18.13.0
Published on
Jan 10, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Enables DOM in Node.js
global-jsdom
will injectdocument
,window
and other DOM API into your Node.js environment. This allows you to run browser tests in Node.js. The specific attributes set onglobal
come directly from thejsdom
version you have installed.
global-jsdom
uses the same major version as the jsdom
that it wraps.
Requires node >= 18.
npm install --save-dev --save-exact jsdom global-jsdom
Just invoke it to turn your Node.js environment into a DOM environment.
1// commonjs 2require('global-jsdom/register') 3 4// or es2015 5import 'global-jsdom/register' 6 7// you can now use the DOM 8document.body.innerHTML = 'hello' 9 10// you can also access the current jsdom instance through $jsdom 11global.$jsdom.reconfigure({})
You may pass configuration parameters to jsdom
like so:
1// commonjs 2const globalJsdom = require('global-jsdom') 3 4// or es2015 5import globalJsdom from 'global-jsdom' 6 7// then 8globalJsdom(html, options)
Check the jsdom.jsdom() documentation for valid values for the options
parameter.
The following set of default options are passed to jsdom
1{ 2 // if url isn't set then localStorage breaks with a cryptic error, see 3 // https://github.com/jsdom/jsdom/issues/2304#issuecomment-408320484 4 url: 'http://localhost:3000', 5 // pretendToBeVisual is enabled so that react works, see 6 // https://github.com/jsdom/jsdom#pretending-to-be-a-visual-browser 7 pretendToBeVisual: true, 8}
To clean up the global namespace just invoke the returned function:
1// commonjs 2const cleanup = require('global-jsdom')() 3 4// es2015 5import globalJsdom from 'global-jsdom' 6const cleanup = globalJsdom() 7 8// do things, then 9cleanup()
In tape, run it before your other tests.
1require('global-jsdom/register') 2 3test('your tests', (t) => { 4 /* and so on... */ 5})
Simple: Use Mocha's --require
option. Add this to the test/mocha.opts
file (create it if it doesn't exist)
-r global-jsdom/register
Advanced: For finer control, you can instead add it via mocha's before
and after
hooks.
1before(function () { 2 this.jsdom = require('global-jsdom')() 3}) 4 5after(function () { 6 this.jsdom() 7})
If you're using a recent version of
node then import
should
just work:
1import 'global-jsdom/register' 2import React from 'react' 3import jQuery from 'jquery' 4// ...
The library includes automatic support providing the necessary type declarations for an integration without further configuration.
1import globalJsdom from "global-jsdom"; 2 3describe("Typescript test example", () => { 4 let cleanup: { (): void }; 5 6 before(() => { 7 cleanup = globalJsdom(); 8 }); 9 10 after(() => { 11 cleanup(); 12 }); 13 14})
original code forked from jsdom-global
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 3/17 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More