-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtest-bundler.js
37 lines (31 loc) · 1.25 KB
/
test-bundler.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
// ---------------------------------------
// Test Environment Setup
// ---------------------------------------
import sinon from 'sinon'
import chai from 'chai'
import sinonChai from 'sinon-chai'
import chaiAsPromised from 'chai-as-promised'
import chaiEnzyme from 'chai-enzyme'
chai.use(sinonChai)
chai.use(chaiAsPromised)
chai.use(chaiEnzyme())
global.chai = chai
global.sinon = sinon
global.expect = chai.expect
global.should = chai.should()
// ---------------------------------------
// Require Tests
// ---------------------------------------
// for use with karma-webpack-with-fast-source-maps
const __karmaWebpackManifest__ = []; // eslint-disable-line
const inManifest = (path) => ~__karmaWebpackManifest__.indexOf(path)
// require all `tests/**/*.spec.js`
const testsContext = require.context('./', true, /\.spec\.js$/)
// only run tests that have changed after the first pass.
const testsToRun = testsContext.keys().filter(inManifest)
;(testsToRun.length ? testsToRun : testsContext.keys()).forEach(testsContext)
// require all `src/**/*.js` except for `main.js` (for isparta coverage reporting)
if (__COVERAGE__) {
const componentsContext = require.context('../src/', true, /^((?!main|reducers).)*\.js$/)
componentsContext.keys().forEach(componentsContext)
}