Skip to content

Commit 22fee68

Browse files
Merge pull request #3506 from PowerShell/andschwa/tests
Update test runner
2 parents f939f5e + 586bb89 commit 22fee68

File tree

8 files changed

+245
-235
lines changed

8 files changed

+245
-235
lines changed

package-lock.json

+220-182
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@types/sinon": "~10.0.2",
6565
"@types/uuid": "~8.3.1",
6666
"@types/vscode": "~1.53.0",
67+
"@vscode/test-electron": "~1.6.2",
6768
"mocha": "~9.0.3",
6869
"mocha-junit-reporter": "~2.0.0",
6970
"mocha-multi-reporters": "~1.5.1",
@@ -72,8 +73,7 @@
7273
"sinon": "~11.1.2",
7374
"tslint": "~6.1.3",
7475
"typescript": "~4.3.5",
75-
"vsce": "~1.96.1",
76-
"vscode-test": "~1.6.1"
76+
"vsce": "~1.96.1"
7777
},
7878
"extensionDependencies": [
7979
"vscode.powershell"

test/platform.test.ts renamed to test/core/platform.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import mockFS = require("mock-fs");
66
import FileSystem = require("mock-fs/lib/filesystem");
77
import * as path from "path";
88
import * as sinon from "sinon";
9-
import * as platform from "../src/platform";
9+
import * as platform from "../../src/platform";
1010

1111
/**
1212
* Describes a platform on which the PowerShell extension should work,

test/settings.test.ts renamed to test/core/settings.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as assert from "assert";
55
import * as vscode from "vscode";
6-
import Settings = require("../src/settings");
6+
import Settings = require("../../src/settings");
77

88
suite("Settings module", () => {
99
test("Settings load without error", () => {

test/fixtures/.gitattributes

-8
This file was deleted.

test/testRunner.ts renamed to test/index.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import * as glob from "glob";
5-
import * as Mocha from "mocha";
4+
// NOTE: This code is borrowed under permission from:
5+
// https://github.com/microsoft/vscode-extension-samples/tree/main/helloworld-test-sample/src/test
6+
67
import * as path from "path";
8+
import * as Mocha from "mocha";
9+
import * as glob from "glob";
710

811
export function run(): Promise<void> {
912
// Create the mocha test
1013
const mocha = new Mocha({
11-
ui: "tdd", // the TDD UI is being used in extension.test.ts (suite, test, etc.)
14+
ui: "tdd",
1215
color: !process.env.TF_BUILD, // colored output from test results
1316
reporter: "mocha-multi-reporters",
1417
timeout: 5000,
@@ -23,24 +26,26 @@ export function run(): Promise<void> {
2326
const testsRoot = path.resolve(__dirname, "..");
2427

2528
return new Promise((c, e) => {
26-
glob("**/**.test.js", { cwd: testsRoot }, (err: any, files: any[]) => {
29+
glob("**/**.test.js", { cwd: testsRoot }, (err, files) => {
2730
if (err) {
2831
return e(err);
2932
}
3033

3134
// Add files to the test suite
32-
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
35+
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
3336

3437
try {
3538
// Run the mocha test
36-
mocha.run((failures) => {
39+
mocha.run(failures => {
3740
if (failures > 0) {
3841
e(new Error(`${failures} tests failed.`));
3942
} else {
4043
c();
4144
}
4245
});
4346
} catch (err) {
47+
// tslint:disable-next-line:no-console
48+
console.error(err);
4449
e(err);
4550
}
4651
});

test/runTests.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import * as path from "path";
4+
// NOTE: This code is borrowed under permission from:
5+
// https://github.com/microsoft/vscode-extension-samples/tree/main/helloworld-test-sample/src/test
56

6-
import { runTests } from "vscode-test";
7+
import * as path from "path";
78

8-
// tslint:disable-next-line: no-var-requires
9-
const PackageJSON: any = require("../../package.json");
10-
const testExtensionId = `${PackageJSON.publisher}.${PackageJSON.name}`;
9+
import { runTests } from "@vscode/test-electron";
1110

1211
async function main() {
1312
try {
1413
// The folder containing the Extension Manifest package.json
1514
// Passed to `--extensionDevelopmentPath`
1615
const extensionDevelopmentPath = path.resolve(__dirname, "../../");
1716

18-
// The path to the extension test runner script
17+
// The path to the extension test script
1918
// Passed to --extensionTestsPath
20-
const extensionTestsPath = path.resolve(__dirname, "./testRunner");
19+
const extensionTestsPath = path.resolve(__dirname, "./index");
2120

22-
// Download VS Code, unzip it and run the integration test from the local directory.
21+
// Download VS Code, unzip it and run the integration test
2322
await runTests({
2423
extensionDevelopmentPath,
2524
extensionTestsPath,
26-
launchArgs: [
27-
"--disable-extensions",
28-
"--enable-proposed-api", testExtensionId,
29-
"./test"
30-
],
25+
launchArgs: ["--disable-extensions", "./test"],
26+
// This is necessary because the tests fail if more than once
27+
// instance of Code is running.
3128
version: "insiders"
3229
});
3330
} catch (err) {
34-
// tslint:disable-next-line:no-console
35-
console.error(err);
3631
// tslint:disable-next-line:no-console
3732
console.error("Failed to run tests");
3833
process.exit(1);

test/test_utils.ts

-20
This file was deleted.

0 commit comments

Comments
 (0)