forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (38 loc) · 1.01 KB
/
index.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
require('app-module-path').addPath(`${__dirname}'./../`);
import Minimist from 'minimist';
import Mocha from 'mocha';
import Glob from 'glob';
import './utils/dom';
const argv = Minimist(process.argv.slice(2), {
alias: {
c: 'component',
g: 'grep',
},
});
const types = argv._;
const globPatterns = {
unit: `src/**/${argv.component ? argv.component : '*'}.spec.js`,
integration: `test/integration/**/${argv.component ? argv.component : '*'}.spec.js`,
};
let pattern;
if (types.indexOf('unit') + types.indexOf('integration') === -2) {
pattern = Object.keys(globPatterns).map((n) => globPatterns[n]);
} else {
pattern = types.map((n) => globPatterns[n]);
}
const mocha = new Mocha({
grep: argv.grep ? argv.grep : undefined,
reporter: 'dot',
});
Glob(
pattern.length > 1 ? `{${pattern.join(',')}}` : pattern[0],
{},
(err, files) => {
files.forEach((file) => mocha.addFile(file));
mocha.run((failures) => {
process.on('exit', () => {
process.exit(failures);
});
});
}
);