Update Pester to 6.0.0#751
Conversation
Change RequiredModules.psd1 from the floating Pester latest pin to the 6.0.0-rc1 prerelease pin. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WalkthroughThe PR pins Pester to 6.0.0 and updates Active Directory DSC unit tests for Pester 6 mock forwarding, verbose-call handling, and verifiable-mock assertions. ChangesPester 6 migration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Pester v6 no longer falls through to the real command when a mock has only -ParameterFilter behaviours and none of them match - it throws instead. Restore the v5 behaviour the tests relied on by forwarding unmatched Test-Path calls to the real cmdlet, and suppress unmatched Write-Verbose calls (scoping the related Should -Invoke assertion to the asserted message so the count stays correct). Also replace the removed Assert-VerifiableMock with Should -InvokeVerifiable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Re-run the release-candidate pilot against Pester 6.0.0-rc2, which includes the revert of the Should -HaveCount dictionary-counting change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ster 6 In the 'When no domain controller is found' context, Pester 6 throws instead of falling through to the real command when a mock has only -ParameterFilter behaviours and none match. Add a default Write-Verbose mock to swallow the unmatched verbose call and scope the related Should -Invoke assertion to the asserted message so the count stays at 1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #751 +/- ##
===================================
- Coverage 99% 99% -1%
===================================
Files 25 25
Lines 3710 3714 +4
===================================
+ Hits 3683 3684 +1
- Misses 27 30 +3 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I am actually not sure how to solve the conflict. Leaving this to you to fix or close. Thanks! |
|
The build fails for unknown reasons. Leaving it open for someone to investigate when time permits. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
CHANGELOG.md (1)
12-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUpdate the changelog if
Write-Verbosetesting is removed.If you remove the
Write-Verbosemocks as suggested in the consolidated comment below, please update this bullet point to remove the mention of suppressing unmatchedWrite-Verbosecalls. Additionally, wrap the lines at 80 characters to comply with the Markdown style guidelines.📝 Proposed update
- `ActiveDirectoryDsc` - - Updated unit tests for Pester 6 compatibility - forward unmatched `Test-Path` - mock calls to the real cmdlet, suppress unmatched `Write-Verbose` calls, and - replace the removed `Assert-VerifiableMock` with `Should -InvokeVerifiable`. + - Updated unit tests for Pester 6 compatibility - forward unmatched + `Test-Path` mock calls to the real cmdlet, and replace the removed + `Assert-VerifiableMock` with `Should -InvokeVerifiable`.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@CHANGELOG.md` around lines 12 - 15, Update the ActiveDirectoryDsc changelog entry to remove the reference to suppressing unmatched Write-Verbose calls if those mocks were removed, and rewrap the bullet text so each line is no longer than 80 characters.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/Unit/ActiveDirectoryDsc.Common/ActiveDirectoryDsc.Common.Tests.ps1`:
- Around line 1650-1653: Remove all Write-Verbose mocks and Should -Invoke
assertions from
tests/Unit/ActiveDirectoryDsc.Common/ActiveDirectoryDsc.Common.Tests.ps1 at
lines 1650-1653 and 1664-1670, and from
tests/Unit/MSFT_WaitForADDomain.Tests.ps1 at lines 160-162 and 191-193. Let real
verbose output execute without adding empty fallback mocks or testing verbose
messages.
---
Nitpick comments:
In `@CHANGELOG.md`:
- Around line 12-15: Update the ActiveDirectoryDsc changelog entry to remove the
reference to suppressing unmatched Write-Verbose calls if those mocks were
removed, and rewrap the bullet text so each line is no longer than 80
characters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 07ab8c0f-861c-4090-9b06-7df910525ed1
📒 Files selected for processing (5)
CHANGELOG.mdRequiredModules.psd1tests/Unit/ActiveDirectoryDsc.Common/ActiveDirectoryDsc.Common.Tests.ps1tests/Unit/MSFT_ADDomain.Tests.ps1tests/Unit/MSFT_WaitForADDomain.Tests.ps1
Pester 6.0.0 is now released 🎉 — thanks for letting me pilot the release candidates against your suite.
This updates the earlier release-candidate pin to the final 6.0.0 and keeps the test changes needed to run on Pester 6 (already in this PR). It's the same migration you'd make yourself, so you're welcome to merge it, cherry-pick just the compatibility changes, or use it purely as a reference.
Your unit tests pass on 6.0.0. The remaining red HQRM check is this repo's own custom PSScriptAnalyzer rules (e.g.
Measure-Keyword), unrelated to Pester.The real-world CI signal from this pilot was genuinely valuable in getting 6.0.0 right. Thanks for the CI time this used, and for maintaining a suite I could test against.
This PR was co-authored by GitHub Copilot.
— Jakub & Copilot
This change is