diff --git a/package.json b/package.json index 341b4623a3..94099f6893 100644 --- a/package.json +++ b/package.json @@ -204,6 +204,16 @@ "title": "Create New Project from Plaster Template", "category": "PowerShell" }, + { + "command": "PowerShell.RunPesterTestsFromFile", + "title": "Run Pester tests", + "category": "PowerShell" + }, + { + "command": "PowerShell.DebugPesterTestsFromFile", + "title": "Debug Pester tests", + "category": "PowerShell" + }, { "command": "PowerShell.OpenExamplesFolder", "title": "Open Examples Folder", @@ -233,6 +243,16 @@ "group": "2_powershell" } ], + "editor/title/context": [ + { + "when": "resourceFilename =~ /\\.tests\\.ps1$/i", + "command": "PowerShell.RunPesterTestsFromFile" + }, + { + "when": "resourceFilename =~ /\\.tests\\.ps1$/i", + "command": "PowerShell.DebugPesterTestsFromFile" + } + ], "view/title": [ { "command": "PowerShell.RefreshCommandsExplorer", diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index 1cdbfc1298..45111e295b 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -15,6 +15,17 @@ export class PesterTestsFeature implements IFeature { private languageClient: LanguageClient; constructor(private sessionManager: SessionManager) { + this.command = vscode.commands.registerCommand( + "PowerShell.RunPesterTestsFromFile", + () => { + this.launchTests(vscode.window.activeTextEditor.document.uri, false); + }); + this.command = vscode.commands.registerCommand( + "PowerShell.DebugPesterTestsFromFile", + () => { + this.launchTests(vscode.window.activeTextEditor.document.uri, true); + }); + // This command is provided for usage by PowerShellEditorServices (PSES) only this.command = vscode.commands.registerCommand( "PowerShell.RunPesterTests", (uriString, runInDebugger, describeBlockName?) => {