Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsdom-global

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdom-global - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

7

HISTORY.md

@@ -0,1 +1,8 @@

## [v1.1.0]
> Jan 11, 2016
- Add `cleanup()`.
[v1.1.0]: https://github.com/rstacruz/jsdom-global/compare/v1.0.0...v1.1.0
## [v1.0.0]

@@ -2,0 +9,0 @@ > Jan 11, 2016

11

index.js

@@ -8,6 +8,6 @@ /*

try {
var keys = globalize()
var cleanup = globalize()
return func()
} finally {
keys.forEach(function (key) { delete global[key] })
cleanup()
}

@@ -43,3 +43,8 @@ } else {

window.console = global.console
return keys
function cleanup () {
keys.forEach(function (key) { delete global[key] })
}
return cleanup
}
{
"name": "jsdom-global",
"version": "1.0.0",
"version": "1.1.0",
"description": "Enable DOM in Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -31,2 +31,13 @@ # jsdom-global

To clean up after itself, just invoke the function it returns.
```js
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.

@@ -41,2 +52,4 @@

## Tape
In [tape][], run it before your other tests.

@@ -65,4 +78,18 @@

## Mocha
Just add it to [mocha]'s `before` and `after` hooks.
```js
before(function () {
this.jsdom = require('jsdom-global')()
})
after(function () {
this.jsdom()
})
```
[tape]: https://github.com/substack/tape
[mocha]: https://mochajs.org/

@@ -69,0 +96,0 @@ ## Thanks

var test = require('tape')
var jsdom
test('jsdom', require('./tape')())
test('jsdom', function (t) {
jsdom = require('./index')()
t.end()
})

@@ -12,1 +16,8 @@ test('dom', function (t) {

})
test('cleanup', function (t) {
jsdom()
t.ok(typeof global.document === 'undefined', 'cleaned document')
t.ok(typeof global.alert === 'undefined', 'cleaned alert')
t.end()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc