Created
August 5, 2015 11:38
-
-
Save nikolaymatrosov/3c9636a5c46b4022535e to your computer and use it in GitHub Desktop.
Mocha test setup for testing React using JsDOM
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
{ | |
... | |
"scripts": { | |
"test": "mocha --recursive --require test_setup.js src/**/*.spec.js", | |
}, | |
"devDependencies": { | |
"babel": "5.6.14", | |
"babel-core": "5.6.20", | |
"babel-plugin-rewire": "0.1.5", | |
"chai": "3.0.0", | |
"jsdom": "3.1.2", | |
"mocha": "2.2.5", | |
"sinon": "1.15.4" | |
} | |
... | |
} |
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
require('babel/register')({ | |
stage: 0, | |
plugins: ['rewire'] | |
}); | |
var jsdom = require('jsdom').jsdom('<!doctype html><html><body></body></html>'); | |
global.document = jsdom; | |
global.window = document.parentWindow; | |
global.navigator = window.navigator; | |
global.expect = require('chai').expect; | |
global.assert = require('chai').assert; | |
var sinon = require('sinon'); | |
var sinonStubPromise = require('sinon-stub-promise'); | |
sinonStubPromise(sinon); | |
global.sinon = sinon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment