From 70209f3dfdf092d5b3e4bc1a3de5b8d2612e34aa Mon Sep 17 00:00:00 2001 From: Trent Blackburn <45049539+tablackburn@users.noreply.github.com> Date: Thu, 28 May 2026 01:05:02 -0400 Subject: [PATCH] Clarify that Set-ItResult ends the It block in Pester v5 Skip section (#1857) Set-ItResult -Skipped/-Inconclusive throws internally to end the It block, so code after it does not run and a trailing return is unreachable. Documenting this prevents the recurring suggestion to add a redundant return after Set-ItResult. Co-authored-by: Claude Opus 4.7 (1M context) --- instructions/powershell-pester-5.instructions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/instructions/powershell-pester-5.instructions.md b/instructions/powershell-pester-5.instructions.md index 78b81ada..821ae34d 100644 --- a/instructions/powershell-pester-5.instructions.md +++ b/instructions/powershell-pester-5.instructions.md @@ -121,6 +121,7 @@ Invoke-Pester -TagFilter 'Unit' -ExcludeTagFilter 'Slow' - **`-Skip`**: Available on `Describe`, `Context`, and `It` to skip tests - **Conditional**: Use `-Skip:$condition` for dynamic skipping - **Runtime Skip**: Use `Set-ItResult -Skipped` during test execution (setup/teardown still run) +- **Ends the test body**: `Set-ItResult -Skipped`/`-Inconclusive` throws internally to end the `It` block, so code after it does not run; a trailing `return` is unreachable and should not be added ```powershell It 'Should work on Windows' -Skip:(-not $IsWindows) { }