Make the CI pipeline work with Pester 5 and later - #1743
Open
Mike-Crowley wants to merge 1 commit into
Open
Conversation
Every Azure Pipelines job installs the latest Pester and then runs CI/CI.ps1, which still used the Pester 4 invocation syntax, so every job on every PR failed before running a single test: Invoke-Pester : A parameter cannot be found that matches parameter name 'OutputFile'. CI.ps1 now builds a configuration object via New-PesterConfiguration when it is available (Pester 5+), producing the same NUnit test-results file and tag filtering as before, and falls back to the original parameters on older Pester. Failed tests are listed from the v5 result object's Failed collection. With the invocation fixed, five tests still fail under Pester 5+ because Set-ItResult -Pending no longer exists; those known-EPPlus-bug placeholders now use -Skipped, which both Pester 4.7+ and 5+ support. Compare-WorkSheet's Windows PowerShell GridView test also now launches its child process with -EncodedCommand: passing the command via -Command mangled the embedded quotes, which broke the test whenever the repository path contains spaces (CI agents were unaffected). Verified by running ./CI/CI.ps1 -Test end to end with Pester 6.0.1 on PowerShell 7 (277 passed, 0 failed) and Windows PowerShell 5.1 (287 total, 0 failures), plus -TestImportOnly (tag filter selects the single import test), and confirming the NUnit XML matches what PublishTestResults expects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 29, 2026
There was a problem hiding this comment.
Pull request overview
Updates the repository’s CI test runner and a handful of tests to be compatible with Pester 5+ (while keeping a Pester 4 fallback), unblocking Azure Pipelines from failing before tests execute.
Changes:
- Updated
CI/CI.ps1to useNew-PesterConfiguration/Invoke-Pester -Configurationwhen available (Pester 5+), retaining the legacy Pester 4 invocation otherwise. - Replaced
Set-ItResult -PendingwithSet-ItResult -Skippedin five placeholder/guard tests to avoid Pester 5+ parameter-set failures. - Fixed Windows PowerShell child process invocation in
Compare-WorkSheet.tests.ps1by switching to-EncodedCommandto avoid quote-mangling when paths contain spaces.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| CI/CI.ps1 | Switches CI Pester invocation to configuration-object mode for Pester 5+ while preserving Pester 4 behavior. |
| tests/PasswordProtection.tests.ps1 | Updates placeholder test outcome from Pending to Skipped for Pester 5+ compatibility. |
| tests/Join-Worksheet.tests.ps1 | Updates placeholder test outcome from Pending to Skipped for Pester 5+ compatibility. |
| tests/First10Races.tests.ps1 | Updates placeholder test outcome from Pending to Skipped for Pester 5+ compatibility. |
| tests/ExtraLongCmd.tests.ps1 | Updates placeholder test outcome from Pending to Skipped for Pester 5+ compatibility. |
| tests/Export-Excel.Tests.ps1 | Updates placeholder test outcome from Pending to Skipped for Pester 5+ compatibility. |
| tests/Compare-WorkSheet.tests.ps1 | Uses powershell.exe -EncodedCommand to make module import robust when repo paths contain spaces. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #1744
Problem
Every Azure Pipelines job currently fails on every PR — including trivial ones — before running a single test. All six jobs (e.g. on #1721, #1723, #1729, #1741, #1742) stop in the "Install and Test" step with:
The pipeline's "Update Pester" step installs the latest Pester (currently 6.x) on every agent, but
CI/CI.ps1still uses the Pester 4 invocation syntax:-OutputFilewas removed in Pester 5, and the result object'sTestResultproperty becameTests/Failed.Changes
CI/CI.ps1— whenNew-PesterConfigurationexists (Pester 5+), build a configuration object instead:TestResult.Enabled+OutputPathproduce the sameTestResultsPS<version>.xmlNUnit file thePublishTestResultstask consumes (the default output format is NUnit 2.5, matching the task'stestResultsFormat: 'NUnit'), andFilter.Tag/Filter.ExcludeTagreproduce theTestImportOnlyhandling. Failed tests are listed from the v5Failedcollection. On older Pester the original code runs unchanged.Five tests — with the invocation fixed, five tests still fail under Pester 5+ because
Set-ItResult -Pendingno longer exists (Parameter set cannot be resolved...). These are all placeholders for known EPPlus 4.5 bugs (plus one "can't test passwords on PS6+" guard); they now use-Skipped, which Pester 4.7+ and 5+ both support:Export-Excel.Tests.ps1,ExtraLongCmd.tests.ps1,First10Races.tests.ps1,Join-Worksheet.tests.ps1("Bug in EPPLus 4.5")PasswordProtection.tests.ps1("Can't test passwords on V6 and later")Compare-WorkSheet.tests.ps1— the Windows PowerShell GridView test spawns a childpowershell.exe -Command $cmdline; native argument passing mangles the embedded quotes, so the child'sImport-Modulefails whenever the repository path contains spaces and the test fails withExpected 'FF90EE90', but got $null. CI agents (D:\a\1\s) never see this, but local contributors with spaces in their clone path do. The child is now launched with-EncodedCommand, which sidesteps quoting entirely.Verification
Ran
./CI/CI.ps1 -Testend to end (includingCI/Install.ps1, against a sandboxedPSModulePath) with Pester 6.0.1:./CI/CI.ps1 -TestImportOnlyAlso verified the failure branch behaves (a failing test produces the "Test failures:" listing and a non-zero exit), and that the produced
TestResultsPS*.xmlis valid NUnit 2.5 with onetest-caseper test.This should let the pipeline actually validate the open PRs again.
🤖 Generated with Claude Code