You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set-Alias-Name v -Value 'vncviewer.exe'; 1|Assert-Equivalent-Expected 2
Output:
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:598
Line |598| v "`$Expected has type $(Get-Type$Expected), `$Actual has type $ … | ~ | The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify | that the path is correct and try again.v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:604Line | 604 | v "`$Expected is a value (value type, string, single value ar …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:207
Line |207| v "Equivalency comparator is used, values will be compared fo … | ~ | The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify | that the path is correct and try again.v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:256Line | 256 | v "Comparing values as $(Format-Nicely (Get-Type$Expected)) beca …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:262
Line |262| v -Difference "`$Actual is not equivalent to $(Format-Nicely …| ~| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify| that the path is correct and try again.OperationStopped: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:676Line |676|throw [Assertions.AssertionException]$message| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Expected and actual are not equivalent! Expected: 2 Actual: 1 Summary: Expected '2' to be equivalent to the actual value, but got '1'.
The issue is caused by the command resolution order in PowerShell that gives aliases higher precedence than functions. Assert-Equivalent defines v function (line 519) that is overshadowed by the v alias:
functionv {
[CmdletBinding()]
param(
[String] $String,
[Switch] $Difference,
[Switch] $Equivalence,
[Switch] $Skip
)
# we are using implict variable $Path# from the parent scope, this is ugly# and bad practice, but saves us ton of# coding and boilerplate code$p=""$p+=if ($null-ne$Path) {
"($Path)"
}
$p+=if ($Difference) {
" DIFFERENCE"
}
$p+=if ($Equivalence) {
" EQUIVALENCE"
}
$p+=if ($Skip) {
" SKIP"
}
$p+=if (""-ne$p) {
" - "
}
Write-Verbose ("$p$String".Trim() +"")
}
@nohwnd: Since the assert functions have been moved to Pester v6, would you accept PR to Assert module fixing the issue? I have noticed that in Pester v6 the v function has been renamed to Write-EquivalenceResult. I could backport it to the Assert module if you are still accepting the PRs.
For others, the workaround is not to use v alias 🤷♂️
Edit:
I have done the PR anyways... could not help myself 😜
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Steps to reproduce:
Output:
The issue is caused by the command resolution order in PowerShell that gives aliases higher precedence than functions.
Assert-Equivalent
definesv
function (line 519) that is overshadowed by thev
alias:@nohwnd: Since the assert functions have been moved to
Pester v6
, would you accept PR toAssert
module fixing the issue? I have noticed that inPester v6
thev
function has been renamed toWrite-EquivalenceResult
. I could backport it to theAssert
module if you are still accepting the PRs.For others, the workaround is not to use
v
alias 🤷♂️Edit:
I have done the PR anyways... could not help myself 😜
The text was updated successfully, but these errors were encountered: