![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
jsdom-global
Advanced tools
Changelog
[v1.3.0]
Jan 11, 2016
Readme
Enables DOM in Node.js
jsdom-global will inject document
, window
and other DOM API into your Node.js environment. Useful for tests.
Requires jsdom.
npm install --save-dev --save-exact jsdom jsdom-global
Just invoke it to turn your Node.js environment into a DOM environment.
var jsdom = require('jsdom-global')
jsdom()
// you can now use the DOM
document.body.innerHTML = 'hello'
To clean up after itself, just invoke the function it returns.
var jsdom = require('jsdom-global')
var cleanup = jsdom()
// do things
cleanup()
You can also invoke it with a function block so it'll clean up afterwards.
jsdom(function () {
var $ = require('jquery')
$('body').html('hello')
})
In tape, run it before your other tests.
var test = require('tape')
// example: run your tests with `env JSDOM=1` to enable jsdom in an otherwise
// browser-only test
if (process.env.JSDOM) {
test('jsdom', (t) => {
require('jsdom-global')()
t.pass('jsdom enabled')
t.end()
})
}
Or even use the tape helper, which will accomplish the same thing:
var test = require('tape')
test('jsdom', require('jsdom-global/tape')())
Just add it to mocha's before
and after
hooks.
before(function () {
this.jsdom = require('jsdom-global')()
})
after(function () {
this.jsdom()
})
jsdom-global © 2016+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz
FAQs
Enable DOM in Node.js
The npm package jsdom-global receives a total of 342,569 weekly downloads. As such, jsdom-global popularity was classified as popular.
We found that jsdom-global demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.