Skip to content

Update Pester to 6.0.0#751

Open
nohwnd wants to merge 7 commits into
dsccommunity:mainfrom
nohwnd:pester-6-rc
Open

Update Pester to 6.0.0#751
nohwnd wants to merge 7 commits into
dsccommunity:mainfrom
nohwnd:pester-6-rc

Conversation

@nohwnd

@nohwnd nohwnd commented Jun 28, 2026

Copy link
Copy Markdown

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 Reviewable

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>
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The 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.

Changes

Pester 6 migration

Layer / File(s) Summary
Pester 6 baseline and changelog
RequiredModules.psd1, CHANGELOG.md
Pins Pester to version 6.0.0 and documents the related test compatibility updates.
Common test mock verification
tests/Unit/ActiveDirectoryDsc.Common/ActiveDirectoryDsc.Common.Tests.ps1
Replaces Assert-VerifiableMock with Should -InvokeVerifiable and updates Write-Verbose mocking and filtering.
Resource test mock behavior
tests/Unit/MSFT_ADDomain.Tests.ps1, tests/Unit/MSFT_WaitForADDomain.Tests.ps1
Forwards unmatched Test-Path calls to the real cmdlet and filters Write-Verbose assertions by message pattern.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating Pester to 6.0.0.
Description check ✅ Passed The description is directly related to the Pester 6.0.0 update and the accompanying test compatibility changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nohwnd and others added 3 commits June 28, 2026 18:47
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

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99%. Comparing base (6f68181) to head (b250f49).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #751   +/-   ##
===================================
- Coverage    99%    99%   -1%     
===================================
  Files        25     25           
  Lines      3710   3714    +4     
===================================
+ Hits       3683   3684    +1     
- Misses       27     30    +3     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

nohwnd and others added 2 commits July 1, 2026 09:33
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd changed the title [DO NOT MERGE] Pester 6.0.0 release candidate update Update Pester to 6.0.0 Jul 7, 2026
@nohwnd

nohwnd commented Jul 8, 2026

Copy link
Copy Markdown
Author

I am actually not sure how to solve the conflict. Leaving this to you to fix or close. Thanks!

@nohwnd
nohwnd marked this pull request as ready for review July 8, 2026 07:22
@johlju

johlju commented Jul 16, 2026

Copy link
Copy Markdown
Member

The build fails for unknown reasons. Leaving it open for someone to investigate when time permits.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
CHANGELOG.md (1)

12-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update the changelog if Write-Verbose testing is removed.

If you remove the Write-Verbose mocks as suggested in the consolidated comment below, please update this bullet point to remove the mention of suppressing unmatched Write-Verbose calls. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6659ae0 and a600bc3.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • RequiredModules.psd1
  • tests/Unit/ActiveDirectoryDsc.Common/ActiveDirectoryDsc.Common.Tests.ps1
  • tests/Unit/MSFT_ADDomain.Tests.ps1
  • tests/Unit/MSFT_WaitForADDomain.Tests.ps1

@johlju johlju added the needs investigation The issue needs to be investigated by the maintainers or/and the community. label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs investigation The issue needs to be investigated by the maintainers or/and the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants