-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
33 lines (27 loc) · 785 Bytes
/
index.ts
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
import * as path from 'path';
import * as Mocha from 'mocha';
import * as mock from 'mock-require';
import * as glob from 'glob';
import {mockVscode} from './vscode.mock';
// `vscode` APIs are only provided when running tests through VS Code (i.e. e2e tests).
// For "standalone" unit tests, we need to mock them.
mock('vscode', mockVscode);
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
});
mocha.useColors(true);
const testsRoot = path.resolve(__dirname);
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
throw err;
}
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
process.exit(1);
}
});
});