Pester
Pester copied to clipboard
Pester stopped working in vscode
Checklist
- [X] Issue has a meaningful title
- [X] I have searched the existing issues. See all issues
- [X] I have tested using the latest version of Pester. See Installation and update guide.
What is the issue?
Error is thrown from vscode:
InvalidOperation: You cannot call a method on a null-valued expression.
InvalidOperation: You cannot call a method on a null-valued expression.
InvalidOperation: You cannot call a method on a null-valued expression.
System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
at System.Management.Automation.CommandProcessorBase.Complete()
at New-PesterState, C:\Program Files\WindowsPowerShell\Modules\Pester\5.5.0\Pester.psm1: line 616
at Invoke-Test, C:\Program Files\WindowsPowerShell\Modules\Pester\5.5.0\Pester.psm1: line 2447
at Invoke-Pester<End>, C:\Program Files\WindowsPowerShell\Modules\Pester\5.5.0\Pester.psm1: line 5046
at <ScriptBlock>, C:\Users\<username>\.vscode\extensions\ms-vscode.powershell-2023.8.0\modules\PowerShellEditorServices\InvokePesterStub.ps1: line 176
at <ScriptBlock>, <No file>: line 1
Note:
Testing works using PowerShell (outside of vscode) using e.g. Invoke-Pester C:\temp\demo.tests.ps1 -Output Detailed
Expected Behavior
Tests are performed
Steps To Reproduce
- open Visual Studio Code (latest stable build)
Version: 1.84.2 (user setup) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:51:52.184Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.22621 - install latest Pester module version (
5.5.0) - create any test file
- define any test
- click
Run testsfrom the editor
Describe your environment
Pester version : 5.5.0 C:\Program Files\WindowsPowerShell\Modules\Pester\5.5.0\Pester.psm1
PowerShell version : 7.4.0
OS version : Microsoft Windows NT 10.0.22621.0
Possible Solution?
No response
Thanks for the report. I'm unable to reproduce the issue. The stacktrace points to an unexpected flow where Pester's run state is missing.
- Is it consistently throwing the same error?
- Does it also work if you change VSCode to use Windows PowerShell?
- Which language mode is your PowerShell session running in? You can check using
$ExecutionContext.SessionState.LanguageMode - Could you provide a test file?
Closing due to inactivity and can't repro. Will reopen if someone's able provide repro steps.