Skip to content

Commit 9ce2dc3

Browse files
Fix hardcoded extension name string (#3222)
* Get `testExtensionId` from `package.json` * Fix `ERR_AMBIGUOUS_ARGUMENT` That `assert.throws` block actually shouldn't have had a message there. I mean, it could have a message, but it was pointless to have it be the message that the assertion throws, as that's not the point of that argument (which is what that error means). https://github.com/nodejs/node/blob/master/doc/api/errors.md#err_ambiguous_argument
1 parent 624e065 commit 9ce2dc3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

test/features/ExternalApi.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import * as vscode from "vscode";
66
import { before, beforeEach, afterEach } from "mocha";
77
import { IExternalPowerShellDetails, IPowerShellExtensionClient } from "../../src/features/ExternalApi";
88

9-
const testExtensionId = "ms-vscode.powershell-preview";
9+
// tslint:disable-next-line: no-var-requires
10+
const PackageJSON: any = require("../../../package.json");
11+
const testExtensionId = `${PackageJSON.publisher}.${PackageJSON.name}`;
1012

1113
suite("ExternalApi feature - Registration API", () => {
1214
let powerShellExtensionClient: IPowerShellExtensionClient;
@@ -42,8 +44,7 @@ suite("ExternalApi feature - Registration API", () => {
4244
*/
4345
test("API fails if not registered", async () => {
4446
assert.rejects(
45-
async () => await powerShellExtensionClient.getPowerShellVersionDetails(""),
46-
"UUID provided was invalid, make sure you ran the 'powershellExtensionClient.registerExternalExtension(extensionId)' method and pass in the UUID that it returns to subsequent methods.");
47+
async () => await powerShellExtensionClient.getPowerShellVersionDetails(""))
4748
});
4849

4950
test("It can't register the same extension twice", async () => {
@@ -82,7 +83,7 @@ suite("ExternalApi feature - Other APIs", () => {
8283
});
8384

8485
beforeEach(() => {
85-
sessionId = powerShellExtensionClient.registerExternalExtension("ms-vscode.powershell-preview");
86+
sessionId = powerShellExtensionClient.registerExternalExtension(testExtensionId);
8687
});
8788

8889
afterEach(() => {

test/runTests.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import * as path from "path";
66

77
import { runTests } from "vscode-test";
88

9+
// tslint:disable-next-line: no-var-requires
10+
const PackageJSON: any = require("../../package.json");
11+
const testExtensionId = `${PackageJSON.publisher}.${PackageJSON.name}`;
12+
913
async function main() {
1014
try {
1115
// The folder containing the Extension Manifest package.json
@@ -22,7 +26,7 @@ async function main() {
2226
extensionTestsPath,
2327
launchArgs: [
2428
"--disable-extensions",
25-
"--enable-proposed-api", "ms-vscode.powershell-preview",
29+
"--enable-proposed-api", testExtensionId,
2630
"./test"
2731
],
2832
version: "insiders"

0 commit comments

Comments
 (0)