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 4 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
13 changes: 12 additions & 1 deletion src/features/PesterTests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*---------------------------------------------------------
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

Expand All @@ -15,6 +15,17 @@ export class PesterTestsFeature implements IFeature {
private languageClient: LanguageClient;

constructor(private sessionManager: SessionManager) {
this.command = vscode.commands.registerCommand(
"PowerShell.RunPesterTestsFromFile",
(uriString, runInDebugger, describeBlockName?) => {
this.launchTests(vscode.window.activeTextEditor.document.uri, false, describeBlockName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth documenting the true and false somehow? I assume it's "start debugger" or similar?

Copy link
Contributor Author

@bergmeister bergmeister Jan 16, 2019

Choose a reason for hiding this comment

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

It's the runInDebugger parameter, which is defined on launchTests, isn't that sufficient/self-documenting? I simplified and minimised the lambda expression, maybe it is clearer now? As far as I've seen, TypeScript does not support named parameters.

});
this.command = vscode.commands.registerCommand(
"PowerShell.DebugPesterTestsFromFile",
(uriString, runInDebugger, describeBlockName?) => {
this.launchTests(vscode.window.activeTextEditor.document.uri, true, describeBlockName);
});
// This command is provided for usage by PowerShellEditorServices (PSES) only
this.command = vscode.commands.registerCommand(
"PowerShell.RunPesterTests",
(uriString, runInDebugger, describeBlockName?) => {
Expand Down