-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathindex.ts
More file actions
47 lines (39 loc) · 1.64 KB
/
index.ts
File metadata and controls
47 lines (39 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-nocheck
// This file is providing the test runner to use when running extension tests.
import * as vscode from 'vscode';
require('mocha/mocha');
import { mockWebviewEnvironment } from '../mocks/mockWebviewEnvironment';
import { EXTENSION_ID } from '../../constants';
async function runAllExtensionTests(testsRoot: string, clb: (error: Error | null, failures?: number) => void): Promise<any> {
// Ensure the dev-mode extension is activated
await vscode.extensions.getExtension(EXTENSION_ID)!.activate();
mockWebviewEnvironment.install(global);
mocha.setup({
ui: 'bdd',
reporter: undefined
});
try {
const importAll = (r: __WebpackModuleApi.RequireContext) => r.keys().forEach(r);
importAll(require.context('../', true, /\.test$/));
} catch (e) {
console.log(e);
}
if (process.env.TEST_JUNIT_XML_PATH) {
mocha.reporter('mocha-multi-reporters', {
reporterEnabled: 'mocha-junit-reporter, spec',
mochaJunitReporterReporterOptions: {
mochaFile: process.env.TEST_JUNIT_XML_PATH,
suiteTitleSeparatedBy: ' / ',
outputs: true,
},
});
}
return mocha.run(failures => clb(null, failures));
}
export function run(testsRoot: string, clb: (error: Error | null, failures?: number) => void): void {
runAllExtensionTests(testsRoot, clb);
}