Skip to content

Commit 6bd68cb

Browse files
committed
[tests] Use Mocha's built-in 'spec' reporter for better test results output...
... instead of 'xunit' and outdated 'mocha-jenkins-reporter'. Also this PR adds a possibility to use `VERBOSE` (boolean) environment variable to force the output of the test results to console when executing the tests locally, f.e.: ``` $ VERBOSE=yes npm test ``` Signed-off-by: Victor Rubezhny <[email protected]>
1 parent 6dcc2c3 commit 6bd68cb

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

build/run-tests.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,29 @@ async function main(): Promise<void> {
1818
const extensionTestsPath = path.resolve(extensionRootPath, 'out', 'test', tests);
1919
const integrationWorkspacePath = path.resolve(extensionRootPath, 'test', 'fixtures', 'components', 'components.code-workspace');
2020
const unitTestWorkspacePath = path.resolve(extensionRootPath, 'test', 'fixtures', 'components', 'empty.code-workspace');
21+
22+
// On some environments, the Mocha reporters do not make amy output to the console when running tests locally if
23+
// tests are invoked without '--verbose' argument. Set the VERBOSE environment variable to any positive boolean value ('true', or 'yes')
24+
// before running the tests to make tests to report to the console, for example:
25+
// ```
26+
// $ export VERBOSE=true
27+
// $ npm test
28+
// ```
29+
// or
30+
// ```
31+
// $ VERBOSE=yes npm test
32+
// ```
33+
//
34+
const boolPattern = /^(true|1|yes)$/i;
35+
const verbose = boolPattern.test(process.env.VERBOSE);
2136
try {
2237
await etest.runTests({
2338
extensionDevelopmentPath,
2439
extensionTestsPath,
2540
launchArgs: [
2641
tests === 'integration' ? integrationWorkspacePath : unitTestWorkspacePath,
2742
'--disable-workspace-trust',
43+
verbose ? '--verbose' : ''
2844
],
2945
});
3046
} catch (err) {

test/integration/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ import { CoverageRunner, TestRunnerOptions } from '../coverage';
1313
sourceMapSupport.install();
1414

1515
const config: Mocha.MochaOptions = {
16-
reporter: 'xunit',
16+
// Previously used reporter ('mocha-jenkins-reporter') has been removed as deprecated.
17+
// We're currently not using Jenkins, but if needed, it's probably better to use `xunit` reporter instead
18+
// when we're testing on Jenkins. Also, probably this will need an adoption on how the test report is to be
19+
// stored on Jenkins (something like `reporterOptions: { output: 'report.xml' }` is to be added to MochaOptions
20+
// in order to output xunit results to the file to be processed on Jenkins).
21+
//
22+
// reporter: process.env.JUNIT_REPORT_PATH ? 'mocha-jenkins-reporter' : 'spec',
23+
reporter: 'spec',
1724
ui: 'tdd',
1825
timeout: 120000,
1926
color: true,

test/ui/.mocharc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

33
module.exports = {
4-
reporter: process.env.JUNIT_REPORT_PATH ? 'xunit' : 'spec',
4+
reporter: 'spec',
55
timeout: 7000,
66
};

test/unit/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sourceMapSupport.install();
1414

1515

1616
const config: Mocha.MochaOptions = {
17-
reporter: 'xunit',
17+
reporter: 'spec',
1818
ui: 'tdd',
1919
timeout: 60000,
2020
color: true,

test/vsix-test/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Mocha from 'mocha';
99
import * as paths from 'path';
1010

1111
const config: Mocha.MochaOptions = {
12-
reporter: 'xunit',
12+
reporter: 'spec',
1313
ui: 'tdd',
1414
timeout: 15000,
1515
color: true

0 commit comments

Comments
 (0)