Skip to content

Instantly share code, notes, and snippets.

@parris
Created August 4, 2014 05:43
Show Gist options
  • Save parris/8d81b9944579496551e7 to your computer and use it in GitHub Desktop.
Save parris/8d81b9944579496551e7 to your computer and use it in GitHub Desktop.
JSDom + React + Mocha + Sinon
jsdom = require 'jsdom'
require 'mocha-sinon'
# move into beforeEach and flip global.window.close on to improve
# cleaning of environment during each test and prevent memory leaks
document = jsdom.jsdom('<html><body></body></html>', jsdom.level(1, 'core'))
beforeEach ->
@document = document
global.document = @document
global.window = @document.parentWindow
afterEach ->
# setting up and closing a "window" every run is really heavy
# it prevents contamination between tests and prevents memory leaks
# global.window.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment