From b288288d1c9a425ea986c987232759b418c3148f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 28 Jan 2020 20:56:46 +0000 Subject: [PATCH 1/3] Add explorer context menus for 'Run/Debug Pester tests' --- package.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package.json b/package.json index fb743df759..5946a116d6 100644 --- a/package.json +++ b/package.json @@ -287,6 +287,16 @@ "when": "false" } ], + "explorer/context": [ + { + "command": "PowerShell.RunPesterTestsFromFile", + "when": "resourceFilename =~ /\\.tests\\.ps1$/i" + }, + { + "command": "PowerShell.DebugPesterTestsFromFile", + "when": "resourceFilename =~ /\\.tests\\.ps1$/i" + } + ], "editor/context": [ { "when": "editorLangId == powershell", From d96002602f7acb070f88b5e21ae459c966265ddd Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 29 Jan 2020 12:05:34 +0000 Subject: [PATCH 2/3] Make context menu work using file from selected tab/explorer menu --- src/features/PesterTests.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index ea2c5fea9f..904a9e8d48 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -26,14 +26,14 @@ export class PesterTestsFeature implements IFeature { // File context-menu command - Run Pester Tests this.command = vscode.commands.registerCommand( "PowerShell.RunPesterTestsFromFile", - () => { - this.launchAllTestsInActiveEditor(LaunchType.Run); + (fileUri) => { + this.launchAllTestsInActiveEditor(LaunchType.Run, fileUri); }); // File context-menu command - Debug Pester Tests this.command = vscode.commands.registerCommand( "PowerShell.DebugPesterTestsFromFile", - () => { - this.launchAllTestsInActiveEditor(LaunchType.Debug); + (fileUri) => { + this.launchAllTestsInActiveEditor(LaunchType.Debug, fileUri); }); // This command is provided for usage by PowerShellEditorServices (PSES) only this.command = vscode.commands.registerCommand( @@ -51,8 +51,8 @@ export class PesterTestsFeature implements IFeature { this.languageClient = languageClient; } - private launchAllTestsInActiveEditor(launchType: LaunchType) { - const uriString = vscode.window.activeTextEditor.document.uri.toString(); + private launchAllTestsInActiveEditor(launchType: LaunchType, fileUri?: vscode.Uri) { + const uriString = fileUri.toString(); const launchConfig = this.createLaunchConfig(uriString, launchType); launchConfig.args.push("-All"); this.launch(launchConfig); From 26a7e19fe2fe7a7f0bc327b7d5252d2ef3489f0a Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Wed, 29 Jan 2020 17:35:50 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A7=B9=20Cleanup:=20Make=20fileUri=20?= =?UTF-8?q?non-optional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/PesterTests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index 904a9e8d48..5b81655687 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -51,7 +51,7 @@ export class PesterTestsFeature implements IFeature { this.languageClient = languageClient; } - private launchAllTestsInActiveEditor(launchType: LaunchType, fileUri?: vscode.Uri) { + private launchAllTestsInActiveEditor(launchType: LaunchType, fileUri: vscode.Uri) { const uriString = fileUri.toString(); const launchConfig = this.createLaunchConfig(uriString, launchType); launchConfig.args.push("-All");