Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/integration/electron/testrunner.js
3520 views
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
*--------------------------------------------------------------------------------------------*/
5
6
//@ts-check
7
'use strict';
8
9
const paths = require('path');
10
const glob = require('glob');
11
// Linux: prevent a weird NPE when mocha on Linux requires the window size from the TTY
12
// Since we are not running in a tty environment, we just implement the method statically
13
const tty = require('tty');
14
// @ts-ignore
15
if (!tty.getWindowSize) {
16
// @ts-ignore
17
tty.getWindowSize = function () { return [80, 75]; };
18
}
19
const Mocha = require('mocha');
20
21
let mocha = new Mocha({
22
ui: 'tdd',
23
color: true
24
});
25
26
exports.configure = function configure(opts) {
27
mocha = new Mocha(opts);
28
};
29
30
exports.run = function run(testsRoot, clb) {
31
// Enable source map support
32
require('source-map-support').install();
33
34
// Glob test files
35
glob('**/**.test.js', { cwd: testsRoot }, function (error, files) {
36
if (error) {
37
return clb(error);
38
}
39
try {
40
// Fill into Mocha
41
files.forEach(function (f) { return mocha.addFile(paths.join(testsRoot, f)); });
42
// Run the tests
43
mocha.run(function (failures) {
44
clb(null, failures);
45
});
46
}
47
catch (error) {
48
return clb(error);
49
}
50
});
51
};
52
53