|
4 | 4 |
|
5 | 5 | import * as path from 'path'; |
6 | 6 | import * as Mocha from 'mocha'; |
7 | | -// @ts-ignore: all |
8 | 7 | import { glob } from 'glob'; |
9 | 8 |
|
10 | 9 | export function run(): Promise<void> { |
11 | | - // Create the mocha test |
12 | | - const mocha = new Mocha({ |
13 | | - ui: 'tdd', |
14 | | - color: true |
15 | | - }); |
| 10 | + // Create the mocha test |
| 11 | + const mocha = new Mocha({ |
| 12 | + ui: 'tdd', |
| 13 | + color: true |
| 14 | + }); |
16 | 15 |
|
17 | | - const testsRoot = path.resolve(__dirname, '..'); |
| 16 | + const testsRoot = path.resolve(__dirname, '..'); |
18 | 17 |
|
19 | | - return new Promise((c, e) => { |
20 | | - // @ts-ignore: all |
21 | | - glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { |
22 | | - if (err) { |
23 | | - return e(err); |
24 | | - } |
25 | | - |
26 | | - // Add files to the test suite |
27 | | - files.forEach((f: string) => mocha.addFile(path.resolve(testsRoot, f))); |
| 18 | + return new Promise((c, e) => { |
| 19 | + glob('**/**.test.js', { cwd: testsRoot }) |
| 20 | + .then(files => { |
| 21 | + // Add files to the test suite |
| 22 | + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); |
28 | 23 |
|
29 | | - try { |
30 | | - // Run the mocha test |
31 | | - mocha.run(failures => { |
32 | | - if (failures > 0) { |
33 | | - e(new Error(`${failures} tests failed.`)); |
34 | | - } else { |
35 | | - c(); |
36 | | - } |
37 | | - }); |
38 | | - } catch (err) { |
39 | | - e(err); |
| 24 | + try { |
| 25 | + // Run the mocha test |
| 26 | + mocha.run(failures => { |
| 27 | + if (failures > 0) { |
| 28 | + e(new Error(`${failures} tests failed.`)); |
| 29 | + } else { |
| 30 | + c(); |
40 | 31 | } |
41 | | - }); |
42 | | - }); |
| 32 | + }); |
| 33 | + } catch (err) { |
| 34 | + e(err); |
| 35 | + } |
| 36 | + }) |
| 37 | + .catch(err => { |
| 38 | + return e(err); |
| 39 | + }); |
| 40 | + }); |
43 | 41 | } |
0 commit comments