-
Notifications
You must be signed in to change notification settings - Fork 500
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
Add 'Run/Debug Pester tests' command and file tab menu #1698
Conversation
package.json
Outdated
@@ -233,6 +238,12 @@ | |||
"group": "2_powershell" | |||
} | |||
], | |||
"editor/title/context": [ | |||
{ | |||
"when": "resourceExtname == .ps1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work:
"when": "resourceFilename =~ /\.[Tt]ests\.ps1$/"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I had to escape the backslash in JSON and then your suggestion worked: "resourceFilename =~ /\\.[Tt]ests\\.ps1$/"
The PR is now ready for review :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thinking a bit on the case-insensitivity - maybe it would be better to use /\\.tests\\.ps1$/i
?
You know, we could also add a |
@rkeithhill Thanks for the tip with the completely case insensitive comparison for the |
Just as with your original post, I was thinking that we could have two functions |
Yes, I was even thinking of just changing to make |
Keep in mind that we are sharing this command with the code lens request message we get from PSES. |
…ent file uri. Add support for debugging as well
@rkeithhill Yes, after playing a bit with it, it turned out to be easier to add new commands as you suggested instead of trying to correct the uri logic inside |
src/features/PesterTests.ts
Outdated
this.command = vscode.commands.registerCommand( | ||
"PowerShell.RunPesterTestsFromFile", | ||
(uriString, runInDebugger, describeBlockName?) => { | ||
this.launchTests(vscode.window.activeTextEditor.document.uri, false, describeBlockName); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -17,13 +17,13 @@ export class PesterTestsFeature implements IFeature { | |||
constructor(private sessionManager: SessionManager) { | |||
this.command = vscode.commands.registerCommand( | |||
"PowerShell.RunPesterTestsFromFile", | |||
(uriString, runInDebugger, describeBlockName?) => { | |||
this.launchTests(vscode.window.activeTextEditor.document.uri, false, describeBlockName); | |||
() => { |
There was a problem hiding this comment.
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. :-)
PR Summary
Implements #1667 by adding a command and file tab menu to run all Pester tests on a file. The file tab menu will only appear for
.tests.ps1
files (using a case insensitive comparison).I tested this on Windows 1809 using vscode and the latest vscode-insiders when using Windows PowerShell 5.1. I also made sure that the code lens being used by PSES does not get broken, hence why new commands were added rather than trying to adapt for the different kind of uri in the
launchTests
function. Here is a zip of my locally built vsix for testing: PowerShell-insiders.zipNew file tab menu entries:
Commands:
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
x
between the square brackets.Please mark anything not applicable to this PR
NA
.WIP:
to the beginning of the title and remove the prefix when the PR is ready