PowerShellEditorServices
PowerShellEditorServices copied to clipboard
References CodeLens provider does not show indicators in Untitled files
You need to save the file and then the indicators appear above the Describe statement.
Thanks man! This is because we're checking the file extension to see if it ends with .tests.ps1 before returning symbols, but maybe we should support authoring in untitled files too.
However, now that I think about it, you can't run a Pester test without it being saved to a file... This does actually affect the References CodeLens provider though, so I'll make a fix for that.
You can F5 the file before saving and it runs the tests.
@daviwil do you think you could elaborate on how it affects the References CodeLens provider?
@tylerl0706 This if statement needs to support untitled tabs that contain PowerShell. The main difficulty would be determining that it's definitely PowerShell. Trying to run that on untitled tabs with different languages could cause some nasty unexpected issues.
Status: Ready to close?
Code lens appears after #1098. Command references in untitled documents (with PowerShell language set) are counted since #1917 (included in vscode-powershell v2022.9.0)
Pester code lens (Run/Debug Tests) still require *.tests.ps1 saved files and that should continue imo. to avoid accidently passing this ps1-file to Invoke-Pester just because it mentions Describe/Context/It in a internal scriptblock:
$c = New-PesterConfiguration
$containers = (New-PesterContainer -Data @{ abc = 'def' } -ScriptBlock {
Describe 'd1' {
Context '123' {
It 'a' -Tag 'a.d' { 1 | should -be 1 }
It 'b' -Tag 'a.d' { 1 | should -be 1 } -Skip
}
}
})
$c.Run.Container = $containers
$r = Invoke-Pester -Configuration $c