pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.08k stars 470 forks source link

Pester stopped working in vscode #2408

Closed vojtech-kasny closed 4 months ago

vojtech-kasny commented 9 months ago

Checklist

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

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

fflaten commented 9 months ago

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.

fflaten commented 4 months ago

Closing due to inactivity and can't repro. Will reopen if someone's able provide repro steps.