-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
50 lines (43 loc) · 1.28 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
45
46
47
48
49
50
'use strict';
const path = require('path');
const Mocha = require('mocha');
const glob = require('glob');
const vscode = require('vscode');
function run() {
// Create the mocha test
const mocha = new Mocha({
ui: 'bdd',
color: true
});
mocha.timeout(10000);
const testsRoot = path.resolve(__dirname, '..');
// Activate the extension explicitly
vscode.commands.executeCommand('kb-macro.cancelRecording');
return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
}).finally(() => {
return vscode.commands.executeCommand('workbench.action.closeAllEditors');
});
}
module.exports = {
run
};