-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-bundler.js
40 lines (34 loc) · 1.43 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
38
39
40
// ---------------------------------------
// 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
// NOTE: `new Array()` is used rather than an array literal since
// for some reason an array literal without a trailing `;` causes
// some build environments to fail.
const __karmaWebpackManifest__ = new Array() // 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).)*\.js$/);
componentsContext.keys().forEach(componentsContext);
}