|
1 | 1 | import sourceMapSupport from 'source-map-support'; |
2 | 2 | sourceMapSupport.install(); |
3 | 3 | import Mocha from 'mocha'; |
4 | | -import glob from 'glob'; |
| 4 | +import { glob } from 'glob'; |
5 | 5 | import path from 'path'; |
6 | 6 | import MDBExtensionController from '../../mdbExtensionController'; |
7 | 7 | import { ExtensionContextStub } from './stubs'; |
@@ -37,45 +37,38 @@ export async function run(): Promise<void> { |
37 | 37 |
|
38 | 38 | await mdbTestExtension.testExtensionController.activate(); |
39 | 39 |
|
40 | | - return new Promise((c, e) => { |
41 | | - void glob( |
42 | | - '**/**.test.js', |
43 | | - { |
44 | | - cwd: testsRoot, |
45 | | - ignore: ['**/webview-app/**/*.js'], |
46 | | - }, |
47 | | - (err, files) => { |
48 | | - if (err) { |
49 | | - return e(err); |
50 | | - } |
| 40 | + const files = await glob('**/**.test.js', { |
| 41 | + cwd: testsRoot, |
| 42 | + ignore: ['**/webview-app/**/*.js'], |
| 43 | + }); |
51 | 44 |
|
52 | | - // Add files to the test suite. |
53 | | - files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); |
54 | | - try { |
55 | | - // Run the mocha test. |
56 | | - mocha.run((failures) => { |
57 | | - // Deactivate the extension to properly clean up the language server |
58 | | - void mdbTestExtension.testExtensionController |
59 | | - .deactivate() |
60 | | - .then(() => { |
61 | | - if (failures > 0) { |
62 | | - e(new Error(`${failures} tests failed.`)); |
63 | | - } else { |
64 | | - c(); |
65 | | - } |
66 | | - }) |
67 | | - .catch((deactivateErr) => { |
68 | | - console.error('Error deactivating extension:'); |
69 | | - console.error(deactivateErr); |
70 | | - e(deactivateErr); |
71 | | - }); |
| 45 | + // Add files to the test suite. |
| 46 | + files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); |
| 47 | + |
| 48 | + return new Promise((c, e) => { |
| 49 | + try { |
| 50 | + // Run the mocha test. |
| 51 | + mocha.run((failures) => { |
| 52 | + // Deactivate the extension to properly clean up the language server |
| 53 | + void mdbTestExtension.testExtensionController |
| 54 | + .deactivate() |
| 55 | + .then(() => { |
| 56 | + if (failures > 0) { |
| 57 | + e(new Error(`${failures} tests failed.`)); |
| 58 | + } else { |
| 59 | + c(); |
| 60 | + } |
| 61 | + }) |
| 62 | + .catch((deactivateErr) => { |
| 63 | + console.error('Error deactivating extension:'); |
| 64 | + console.error(deactivateErr); |
| 65 | + e(deactivateErr); |
72 | 66 | }); |
73 | | - } catch (mochaRunErr) { |
74 | | - console.error('Error running mocha tests:'); |
75 | | - console.error(mochaRunErr); |
76 | | - e(mochaRunErr); |
77 | | - } |
78 | | - }, |
79 | | - ); |
| 67 | + }); |
| 68 | + } catch (mochaRunErr) { |
| 69 | + console.error('Error running mocha tests:'); |
| 70 | + console.error(mochaRunErr); |
| 71 | + e(mochaRunErr); |
| 72 | + } |
80 | 73 | }); |
81 | 74 | } |
0 commit comments