Created
August 4, 2014 05:43
-
-
Save parris/8d81b9944579496551e7 to your computer and use it in GitHub Desktop.
JSDom + React + Mocha + Sinon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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