forked from CrocoDillon/universal-react-redux-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocha.config.js
47 lines (36 loc) · 1.09 KB
/
mocha.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Bootstrap babel-register
require('babel-register')
// Ensure correct NODE_ENV
if (process.env.NODE_ENV !== 'test') {
throw new Error('Running tests require NODE_ENV=test')
}
// Globals
global.__DEV__ = true
global.__PROD__ = false
global.__SERVER__ = true
global.__CLIENT__ = false
// Set up chai and sinon
const chai = require('chai')
const sinon = require('sinon')
chai.use(require('chai-as-promised'))
chai.use(require('sinon-chai'))
chai.use(require('chai-enzyme')())
global.expect = chai.expect
global.sinon = sinon
// Set up jsdom
const jsdom = require('jsdom')
const document = new jsdom.JSDOM()
global.document = document
global.window = document.defaultView
global.navigator = { userAgent: 'node.js' }
// Hook for CSS Module imports enables using classes in tests
const hook = require('css-modules-require-hook')
const sass = require('node-sass')
hook({
extensions: ['.scss'],
generateScopedName: '[local]__[hash:base64:4]',
preprocessCss: (css, file) => sass.renderSync({ file }).css
})
// Load tests
const glob = require('glob')
glob.sync('./src/**/*.spec.js').forEach(require)