Skip to content

Commit

Permalink
Add 'Run/Debug Pester tests' command and file tab menu (#1698)
Browse files Browse the repository at this point in the history
* add run pester tests command and file tab menu

* only add menu for tests.ps1 or Tests.ps1 files

* make check for tests.ps1 completely case insensitive

* add new commands to separate concerns due to PSES usage with a different file uri. Add support for debugging as well

* simplify lambda syntax to minimise parameters and revert accidental whitespace change
  • Loading branch information
bergmeister authored and rkeithhill committed Jan 17, 2019
1 parent 869b3c7 commit 68b373f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
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",
() => {
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

0 comments on commit 68b373f

Please sign in to comment.