Closed k00002 closed 1 year ago
I need more information to help you. What were you doing? Do you have an example test that reproduces the issue? What platform are you on?
Whenever I try to expand the target ps1 in vscode's test explorer "An error occured running Pester: hash literal is incomplete." An error occured running Pester: expression or statement token 'duration' cannot be used. An error occured running Pester: Cannot use the token '}' in an expression or statement. and I cannot run the test normally.
When I try to force debugging, Confirmation. Do you want to continue? Y] Yes [A] Continue all [H] Abort command [H] Suspend command [S] [? Help (default is "Y"): y Debugging: PSModulePath: C:\Users*\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;c:\Users*.vscode\extensions\ms-vscode. powershell-2023.6.0\modules" and if you are asked three times and enter "Y" for all of them, you will get the above error message.
The problem areas indicated by the error are In "PesterInterface.ps1 The problematic part of the error message is the following: "function Register-PesterPlugin ([hashtable]$PluginConfiguration) { <# . SYNOPSIS Utilizes a private Pester API to register the plugin.
$Pester = (Get-Command Invoke-Pester -ErrorAction Stop).Module
& $Pester {
param($PluginConfiguration)
if ($null -ne $SCRIPT:additionalPlugins -and $testAdapterPlugin.Name -in $SCRIPT:additionalPlugins.Name) {
Write-Debug "PesterInterface: $($testAdapterPlugin.Name) is already registered.
return
}
if ($null -eq $SCRIPT:additionalPlugins) {
$SCRIPT:additionalPlugins = @())
}
$testAdapterPlugin = New-PluginObject @PluginConfiguration
$SCRIPT:additionalPlugins += $testAdapterPlugin
} $PluginConfiguration
}" in the "$testAdapterPlugin = New-PluginObject @PluginConfiguration".
I think this is happening after changing the "Pester Tests" extension to v2023.7.1. Do you know how to address this? *I'm using google translate, so sorry if it's hard to understand.
Please try using PowerShell 7, make sure you have Pester 5.2.0 or greater installed and try again, I don't do a lot of testing on PowerShell 5.1. If you still have the issue let me know and I can start to take a look.
*The version of pester is 5.5.
ModuleType Version Name ExportedCommands
Script 5.5.0 Pester {Invoke-Pester, Describe, Context, It...}
*The version of PowerShell is 5.1, but cannot be upgraded due to company reasons.
Name Value
PSVersion 5.1.22621.1778 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.1778 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Can you manage to keep PowerShell 5.1? I can provide any other information needed.
I just tested with PS5.1 and it works fine on my computer
Register-PesterPlugin uses a part of pester that was introduced in 5.2. I have a new build that has a version check for that and should error if that's not the case.
Try this VSIX: https://github.com/pester/vscode-adapter/suites/14630159630/artifacts/829649546
https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix
I installed the vsix you gave me, but it did not improve the situation. Is there any way to check if the vsix you taught me is applied? (Sorry to leave this up to you)
Usually the version will say 0.0.0-source
or something that's not the latest
Does that mean there is no way to check?
From the "extention" section, I could see "Pester Tests v0.0.0-source" from the "Extention" section, but the problem does not seem to be resolved.
It looks like when registering the plugin there is a null somewhere. Do you have a specialized Pester configuration or something? Have you tried it with a simple:
Describe 'Test' { It 'TestIt' {$true} }
Test?
I have tried the test you presented, but I am getting errors even before I run it. (Same situation as before)
Go to the Output
pane next to the Terminal
pane, there will be a pester tab
Open the command palette and Set Log Level
to trace
Reload vscode and provide the log trace here (as a text block or attached file, not screenshot, you should be able to highlight, cut, and paste)
Here is the trace
--------------------------------translate-----------------------------------------------
2023-07-28 13:36:16.755 [info] Initializing Pester Test Controller and watching for Pester Files
2023-07-28 13:36:17.325 [info] Detected Pester File: d:\Program\PowerShell\test_tests\Tests\Main.Tests.ps1
2023-07-28 13:36:17.700 [info] Test Discovery Start: 1 files
2023-07-28 13:36:26.837 [debug] PesterInterface Debug: Home: C:\Users*
2023-07-28 13:36:26.839 [debug] PesterInterface Debug: PSModulePath: C:\Users*\Documents\WindowsPowerShell\Modules;C:\Program Files\ WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
2023-07-28 13:36:26.841 [debug] PesterInterface Debug: OutputRendering:.
2023-07-28 13:36:26.853 [error] PesterInterface Error: hash literal is incomplete
2023-07-28 13:36:26.856 [error] PesterInterface Error: Cannot use token 'duration' in expression or statement.
2023-07-28 13:36:26.862 [error] PesterInterface Error: Cannot use token '}' in expression or statement.
2023-07-28 13:36:26.891 [error] PesterInterface Error: Invalid object created with expression after '&' in pipeline element. It must be a command name, script block, or CommandInfo object.
2023-07-28 13:36:27.040 [error] Test Discovery failed: A terminating error was received from PowerShell: Cannot bind to parameter 'Name' because the argument is an empty string.
OK I've been able to reproduce it now, let me see if I can find the problem. thanks for your assistance!
Really!? I am waiting in anticipation.
Very awesome!! and amazing!!
It now functions properly. Thank you very much.
I hope this modification will be reflected in the next update, as I have had a similar issue in previous updates.
Thank you so much for your help!
Yes it will be in the next prerelease. Fixed da2280d65d2302f11bd1435812c8af4995bd5b6d
$pluginModule = Import-PrivateModule $PSScriptRoot/PesterTestPlugin.psm1
発生場所 C:\Users**.vscode\extensions\pspester.pester-test-2023.7.1\Scripts\PesterInterface.ps1:112 文字:18
Import-PrivateModule : 式またはステートメントのトークン 'duration' を使用できません。 発生場所 C:\Users**.vscode\extensions\pspester.pester-test-2023.7.1\Scripts\PesterInterface.ps1:112 文字:18
Import-PrivateModule : 式またはステートメントのトークン '}' を使用できません。 発生場所 C:\Users**.vscode\extensions\pspester.pester-test-2023.7.1\Scripts\PesterInterface.ps1:112 文字:18
パイプライン要素内で '&' の後にある式が無効なオブジェクトを作成しました。コマンド名、スクリプト ブロック、または CommandInfo オブジェクトになる必要があります。 発生場所 C:\Users**.vscode\extensions\pspester.pester-test-2023.7.1\Scripts\PesterInterface.ps1:121 文字:14
New-PluginObject : 引数が空の文字列であるため、パラメーター 'Name' にバインドできません。 発生場所 C:\Users**.vscode\extensions\pspester.pester-test-2023.7.1\Scripts\PesterInterface.ps1:77 文字:41