Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions src/features/PesterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down