Skip to content

Improve examples on the new v6 Should-* assertion pages#377

Open
nohwnd wants to merge 1 commit into
mainfrom
nohwnd-review-new-assertion-docs
Open

Improve examples on the new v6 Should-* assertion pages#377
nohwnd wants to merge 1 commit into
mainfrom
nohwnd-review-new-assertion-docs

Conversation

@nohwnd

@nohwnd nohwnd commented Jun 27, 2026

Copy link
Copy Markdown
Member

What & why

Follow-up to #374, which added command-reference pages for the six new v6 assertions. Those pages are generated from Pester's comment-based help, and several carried over poor or incorrect examples. This PR replaces them with correct, real-life, runnable examples (every one validated against Pester 6.0.0 built from source).

Changes per page

  • Should-Invoke / Should-NotInvoke — dropped the broken {... Some Code ...} placeholders and the un-fenced examples that rendered as escaped text. Use real subjects (Save-Report, Remove-TempFile, Get-Weather) and cover -ParameterFilter, -Times -Exactly, -Scope It, -ModuleName and -ExclusiveFilter. Fixed the Should-NotInvoke explanations, which were copy-pasted from Should-Invoke and described the opposite behavior (e.g. "throws if … is not called").
  • Should-HaveParameter / Should-NotHaveParameter — switched from the old Should -HaveParameter (space) syntax to the new Should-HaveParameter; added -Type / -DefaultValue / -Alias / -InParameterSet examples framed around testing a command's public contract; replaced the failing Should-NotHaveParameter sample with a passing one; removed the irrelevant -HasArgumentCompleter note.
  • Should-MatchString / Should-NotMatchString — replaced the abstract hello / h.*o samples with real-life regex checks (ids, GUIDs, version strings, leftover {{ }} template placeholders, a secret-leak guard).

Validation

  • Every example was run against Pester 6.0.0 (mock examples via Invoke-Pester, the rest standalone) and behaves exactly as the surrounding text claims.
  • yarn build (Docusaurus) succeeds, so all six MDX pages parse and render.

Note on the source of truth

These pages are generated from comment-based help in pester/Pester. I've prepared a matching patch for the inline help so a future regeneration keeps these improvements; it can go in as a follow-up to pester/Pester once this merges.

Relates to pester/Pester#2464.

Replace the carried-over/placeholder examples on the six new v6 assertion
command pages with correct, real-life, runnable examples (validated against
Pester 6.0.0):

- Should-Invoke / Should-NotInvoke: drop the broken {... Some Code ...}
  placeholders and un-fenced examples; use real subjects (Save-Report,
  Remove-TempFile, Get-Weather). Fix Should-NotInvoke explanations that were
  copy-pasted from Should-Invoke and described the wrong behavior.
- Should-HaveParameter / Should-NotHaveParameter: switch from the old
  'Should -HaveParameter' (space) syntax to the new 'Should-HaveParameter';
  add Type/DefaultValue/Alias/InParameterSet examples and a passing
  Should-NotHaveParameter example; drop the irrelevant ArgumentCompleter note.
- Should-MatchString / Should-NotMatchString: replace abstract hello/h.*o
  samples with real-life regex checks (ids, GUIDs, version strings, leftover
  template placeholders, secret-leak guard).

These pages are generated from Pester's comment-based help; the same fixes
should be ported to pester/Pester so regeneration keeps them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant