Created
July 27, 2016 11:11
-
-
Save xiankai/33445f250df2d1bd38857c99a7f54101 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Mocha from 'mocha'; | |
import glob from 'glob'; | |
import _ from 'lodash/lodash'; | |
import chai from 'chai'; | |
import { shallow, mount, render } from 'enzyme'; | |
import chaiEnzyme from 'chai-enzyme'; | |
glob('webroot/components/**/tests/**/*.js', (err, files) => { | |
var runner = new Mocha({ | |
ui: 'bdd', | |
reporter: 'spec', | |
bail: true, | |
fullTrace: true | |
}); | |
chai.use(chaiEnzyme()); | |
global.Assertion = chai.Assertion; | |
global.expect = chai.expect; | |
global.shallow = shallow; | |
global.mount = mount; | |
global.render = render; | |
global._ = _; | |
global.window = global; | |
runner.suite.emit('pre-require', global, 'global-mocha-context', runner); | |
Promise.all( | |
files.map(file => new Promise((resolve, reject) => { | |
SystemJS.import(file.replace('webroot/', '')).then(() => { | |
resolve(); | |
}).catch(err => { | |
reject(err); | |
}); | |
})) | |
).then(() => { | |
runner.run(); | |
}).catch(console.error.bind(console)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment