LSP-client-example
43 строки · 1.1 Кб
1/* --------------------------------------------------------------------------------------------
2* Copyright (c) Microsoft Corporation. All rights reserved.
3* Licensed under the MIT License. See License.txt in the project root for license information.
4* ------------------------------------------------------------------------------------------ */
5import * as path from 'path';
6import * as Mocha from 'mocha';
7import * as glob from 'glob';
8
9export function run(): Promise<void> {
10// Create the mocha test
11const mocha = new Mocha({
12ui: 'tdd',
13color: true
14});
15mocha.timeout(100000);
16
17const testsRoot = __dirname;
18
19return new Promise((resolve, reject) => {
20glob('**.test.js', { cwd: testsRoot }, (err, files) => {
21if (err) {
22return reject(err);
23}
24
25// Add files to the test suite
26files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
27
28try {
29// Run the mocha test
30mocha.run(failures => {
31if (failures > 0) {
32reject(new Error(`${failures} tests failed.`));
33} else {
34resolve();
35}
36});
37} catch (err) {
38console.error(err);
39reject(err);
40}
41});
42});
43}