diff options
author | Aleksey Kladov <[email protected]> | 2020-05-23 15:39:04 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-23 15:39:04 +0100 |
commit | f4f5fca10175b8d5fdfa36563c103f81b2b0acd3 (patch) | |
tree | 456d16e30fb799f82f71cff4c7aa91b0248c0220 /editors/code/tests/unit/index.ts | |
parent | 4cc2ff6e390b6d8015ed1d266425459268f6e0b0 (diff) | |
parent | 1797b665a4dd82ba176b319c850a8875df327a5d (diff) |
Merge pull request #4538 from vsrs/vscode_tests
vscode client side tests
Diffstat (limited to 'editors/code/tests/unit/index.ts')
-rw-r--r-- | editors/code/tests/unit/index.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/editors/code/tests/unit/index.ts b/editors/code/tests/unit/index.ts new file mode 100644 index 000000000..5165720b4 --- /dev/null +++ b/editors/code/tests/unit/index.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import * as path from 'path'; | ||
2 | import Mocha from 'mocha'; | ||
3 | import glob from 'glob'; | ||
4 | |||
5 | export function run(): Promise<void> { | ||
6 | // Create the mocha test | ||
7 | const mocha = new Mocha({ | ||
8 | ui: 'tdd', | ||
9 | color: true | ||
10 | }); | ||
11 | |||
12 | const testsRoot = __dirname; | ||
13 | |||
14 | return new Promise((resolve, reject) => { | ||
15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { | ||
16 | if (err) { | ||
17 | return reject(err); | ||
18 | } | ||
19 | |||
20 | // Add files to the test suite | ||
21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); | ||
22 | |||
23 | try { | ||
24 | // Run the mocha test | ||
25 | mocha.timeout(100000); | ||
26 | mocha.run(failures => { | ||
27 | if (failures > 0) { | ||
28 | reject(new Error(`${failures} tests failed.`)); | ||
29 | } else { | ||
30 | resolve(); | ||
31 | } | ||
32 | }); | ||
33 | } catch (err) { | ||
34 | reject(err); | ||
35 | } | ||
36 | }); | ||
37 | }); | ||
38 | } | ||