Repository navigation
Closed
Description
Checklist
- Issue has a meaningful title
- I have searched the existing issues. See all issues
- I have tested using the latest version of Pester. See Installation and update guide.
What is the issue?
Not sure whether this is a PowerShell a bug or feature but fixing it in PowerShell would probably be a break change.
A side effect of this "feature" is also that it breaks all running Pester tests:
Actual behavior
Starting discovery in 1 files.
Discovery found 3 tests in 47ms.
Running tests.
(no further results)
Expected Behavior
Starting discovery in 1 files.
Discovery found 3 tests in 38ms.
Running tests.
[-] Describe.Context.It 1 27ms (27ms|0ms)
Expected $null or empty, but got 1.
at Test 1 | Should -BeNullOrEmpty, C:\Users\Gebruiker\OneDrive\Scripts\PowerShell\PowerSnippets\ObjectGraph\ObjectGraphTools\_Temp\Test\Pester\Test.ps1:13
at <ScriptBlock>, C:\Users\Gebruiker\OneDrive\Scripts\PowerShell\PowerSnippets\ObjectGraph\ObjectGraphTools\_Temp\Test\Pester\Test.ps1:13
[-] Describe.Context.It 2 37ms (36ms|1ms)
Expected $null or empty, but got @(1, 2).
at Test 2 | Should -BeNullOrEmpty, C:\Users\Gebruiker\OneDrive\Scripts\PowerShell\PowerSnippets\ObjectGraph\ObjectGraphTools\_Temp\Test\Pester\Test.ps1:17
at <ScriptBlock>, C:\Users\Gebruiker\OneDrive\Scripts\PowerShell\PowerSnippets\ObjectGraph\ObjectGraphTools\_Temp\Test\Pester\Test.ps1:17
[-] Describe.Context.It 3 28ms (27ms|1ms)
Expected $null or empty, but got @(1, 2, 3).
at Test 3 | Should -BeNullOrEmpty, C:\Users\Gebruiker\OneDrive\Scripts\PowerShell\PowerSnippets\ObjectGraph\ObjectGraphTools\_Temp\Test\Pester\Test.ps1:21
at <ScriptBlock>, C:\Users\Gebruiker\OneDrive\Scripts\PowerShell\PowerSnippets\ObjectGraph\ObjectGraphTools\_Temp\Test\Pester\Test.ps1:21
Tests completed in 282ms
Tests Passed: 0, Failed: 3, Skipped: 0 NotRun: 0
Or at least:
Tests completed in ...
Tests Passed: ..., Failed: ..., Skipped: ... NotRun: ...
Or an error message
Steps To Reproduce
Function Test($b) {
:foo foreach ($a in 1,2,3) {
$a
if ($a -ge $b) { break bar }
}
}
Describe 'Describe' {
Context 'Context' {
It 'It 1' {
Test 1 | Should -BeNullOrEmpty
}
It 'It 2' {
Test 2 | Should -BeNullOrEmpty
}
It 'It 3' {
Test 3 | Should -BeNullOrEmpty
}
}
}Describe your environment
Pester version : 5.5.0 C:\Users\Gebruiker\Documents\PowerShell\Modules\Pester\5.5.0\Pester.psm1
PowerShell version : 7.5.4
OS version : Microsoft Windows NT 10.0.26100.0
Possible Solution?
Check for unknown labels during discovery?
Metadata
Metadata
Assignees
Labels
No labels
Activity
iRon7 commentedon Jan 27, 2026
Fyi: a resolution for this unexpected PowerShell behavior has been declined: PowerShell/PowerShell#26587 (comment)
I wonder whether there is any intention to resolve this in Pester (see the helpful comment for a possible solution)
iRon7 commentedon Feb 26, 2026
I didn't had much experience with the Pester configuration, but this might help to figure out which test Pester was processed last and could also be helpful in the case of an infinitive loop:
fix(module): replace break-in-try with flag guard in companion-module…
fix(test): pre-load AITriad module at discovery time to avoid LoopFlo…
fix(module): remove continue-in-try from taxonomy loader (t/2609)
fix(module): eliminate all continue/break from taxonomy-loader foreac…
fix(parity-test): use GetTempPath() instead of $env:TEMP for Linux CI…
feat(oped): move op-ed prompts to lib/oped/prompts/ + PS-TS parity ga…
fix(pool): stop the beacon script reconfiguring whoever dot-sources it
fix(pool): stop the beacon script reconfiguring whoever dot-sources it
fix(pool): stop the beacon script reconfiguring whoever dot-sources it
feat(pool): the Windows host's liveness beacon, and a gate that runs …
fix: real Pester v6 failures in the Phase 17 WSL2 lifecycle test suite
chore: Move the build toolchain to psake 5.0.4 (#162)
S18 — Regenerate a development site without partial generations (#35)
Move S15, S17, S18 from Outstanding to Landed (#36)
S19 — Preview the exact promoted artifact (#37)
Keep the real error when user code throws, instead of reporting an es…
fix: pin Pester 5.7.1 — 6.x aborts the whole run under Windows PowerS…
test: local PowerShell testing, and the 5.1-vs-7 difference measured (#…
fix(kindle-dedrm): compare firewall rule state against 'True', not tr…
feat(compliance): collector contract with read-only enforcement
Fix Pester v6 tests: move module setup and helper functions into Befo…
test(ansible): Pester coverage for the two module functions already i…
test(oped): outlet key-set parity gate — PS/TS consumers, both GV arm…
test(ps): characterisation suite for Test-TaxonomyIntegrity, pre-deco…