Skip to content

Fix unit tests for Pester 6 and VS Code host #501 - #502

Merged
NowinskiK merged 4 commits into
masterfrom
issue-501-pester6-tests
Oct 16, 2026
Merged

NowinskiK merged 4 commits into
masterfrom
issue-501-pester6-tests

Conversation

@NowinskiK

Copy link
Copy Markdown
Member

Fixes #501

Summary

Makes the unit tests run reliably on Pester 6 (still compatible with Pester 5) and in the VS Code PowerShell host.

Pester 6 compatibility

  • Replaced Assert-MockCalled (removed in Pester 6) with Should -Invoke. Calling it made PowerShell autoload the built-in Pester 3.4.0, whose Should then shadowed the real one ('-Not' is not a valid Should operator).
  • Test-AdfCode.Tests.ps1: added a default pass-through mock for Get-ChildItem - Pester 6 no longer falls through to the real command when no -ParameterFilter matches.
  • !RunAllTests.ps1: unloads Pester < 5.3.3 before importing.

Host independence

  • !RunAllTests.ps1 and TestHelper\Get-RootPath no longer use $psEditor.GetEditorContext(), which throws in VS Code when the active tab isn't a file. Both now use $PSScriptRoot. Get-RootPath also returned test\TestHelper instead of test in ConsoleHost.

Module change

Other

  • .gitignore: ignore test/**/~*.json temp files produced by unit tests.
  • README: new Running tests locally section (PowerShell 7, modules, Node.js/npm, Az login) and npm prerequisite note for Export-AdfToArmTemplate.
  • Publish-AdfV2FromJson-1.Tests.ps1: temporarily disabled "adf2 Should deploy credential1 to ADF service".

Testing

  • Affected non-Azure test files pass on both Pester 5.7.1 and 6.2.0.
  • PublishOption.Tests.ps1 passes standalone and via the runner.
  • Azure-dependent tests not re-run here (no access to the test subscription during this change).

🤖 Generated with Claude Code

Kamil Nowinski and others added 4 commits October 16, 2026 17:25
…host #501

Removed dependency on $psEditor.GetEditorContext(), which throws in VS Code
host when the active tab is not a file on disk. Also fixes ConsoleHost path
pointing to TestHelper folder instead of test folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ADFT0026 was reported via Write-Error (non-terminating), so whether it
failed depended on the caller's $ErrorActionPreference, making
PublishOption.Tests.ps1 order-dependent. Use throw, consistent with #472.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NowinskiK
NowinskiK changed the base branch from develop to master October 16, 2026 19:10
@NowinskiK
NowinskiK merged commit 9a5524b into master Oct 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests fail with Pester 6 and in VS Code host

1 participant