Skip to content

Add 'Run/Debug Pester tests' command and file tab menu #1698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 17, 2019
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
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions src/features/PesterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ export class PesterTestsFeature implements IFeature {
private languageClient: LanguageClient;

constructor(private sessionManager: SessionManager) {
this.command = vscode.commands.registerCommand(
"PowerShell.RunPesterTestsFromFile",
() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I was just going to suggest this but see you've already done it. :-)

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?) => {
Expand Down