Skip to content

Commit 68b373f

Browse files
bergmeisterrkeithhill
authored andcommitted
Add 'Run/Debug Pester tests' command and file tab menu (#1698)
* 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
1 parent 869b3c7 commit 68b373f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

package.json

+20
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@
204204
"title": "Create New Project from Plaster Template",
205205
"category": "PowerShell"
206206
},
207+
{
208+
"command": "PowerShell.RunPesterTestsFromFile",
209+
"title": "Run Pester tests",
210+
"category": "PowerShell"
211+
},
212+
{
213+
"command": "PowerShell.DebugPesterTestsFromFile",
214+
"title": "Debug Pester tests",
215+
"category": "PowerShell"
216+
},
207217
{
208218
"command": "PowerShell.OpenExamplesFolder",
209219
"title": "Open Examples Folder",
@@ -233,6 +243,16 @@
233243
"group": "2_powershell"
234244
}
235245
],
246+
"editor/title/context": [
247+
{
248+
"when": "resourceFilename =~ /\\.tests\\.ps1$/i",
249+
"command": "PowerShell.RunPesterTestsFromFile"
250+
},
251+
{
252+
"when": "resourceFilename =~ /\\.tests\\.ps1$/i",
253+
"command": "PowerShell.DebugPesterTestsFromFile"
254+
}
255+
],
236256
"view/title": [
237257
{
238258
"command": "PowerShell.RefreshCommandsExplorer",

src/features/PesterTests.ts

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ export class PesterTestsFeature implements IFeature {
1515
private languageClient: LanguageClient;
1616

1717
constructor(private sessionManager: SessionManager) {
18+
this.command = vscode.commands.registerCommand(
19+
"PowerShell.RunPesterTestsFromFile",
20+
() => {
21+
this.launchTests(vscode.window.activeTextEditor.document.uri, false);
22+
});
23+
this.command = vscode.commands.registerCommand(
24+
"PowerShell.DebugPesterTestsFromFile",
25+
() => {
26+
this.launchTests(vscode.window.activeTextEditor.document.uri, true);
27+
});
28+
// This command is provided for usage by PowerShellEditorServices (PSES) only
1829
this.command = vscode.commands.registerCommand(
1930
"PowerShell.RunPesterTests",
2031
(uriString, runInDebugger, describeBlockName?) => {

0 commit comments

Comments
 (0)