Repository navigation
Fix unit tests for Pester 6 and VS Code host #501 - #502
Merged
Merged
Conversation
…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>
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Assert-MockCalled(removed in Pester 6) withShould -Invoke. Calling it made PowerShell autoload the built-in Pester 3.4.0, whoseShouldthen shadowed the real one ('-Not' is not a valid Should operator).Test-AdfCode.Tests.ps1: added a default pass-through mock forGet-ChildItem- Pester 6 no longer falls through to the real command when no-ParameterFiltermatches.!RunAllTests.ps1: unloads Pester < 5.3.3 before importing.Host independence
!RunAllTests.ps1andTestHelper\Get-RootPathno longer use$psEditor.GetEditorContext(), which throws in VS Code when the active tab isn't a file. Both now use$PSScriptRoot.Get-RootPathalso returnedtest\TestHelperinstead oftestin ConsoleHost.Module change
New-AdfPublishOption: missing-FilterFilePathnow throwsADFT0026instead ofWrite-Error, so it fails regardless of the caller's$ErrorActionPreference(consistent with Publish-AdfV2FromJson not yet failing even using errorActionPreference: stop #472). Previously the test was order-dependent, and callers with default EAP silently got empty filters.Other
.gitignore: ignoretest/**/~*.jsontemp files produced by unit tests.Export-AdfToArmTemplate.Publish-AdfV2FromJson-1.Tests.ps1: temporarily disabled "adf2 Should deploy credential1 to ADF service".Testing
PublishOption.Tests.ps1passes standalone and via the runner.🤖 Generated with Claude Code