Skip to content

Improve comment-based help examples for new Should-* assertions#2768

Open
nohwnd wants to merge 1 commit into
mainfrom
improve-new-should-assertion-help
Open

Improve comment-based help examples for new Should-* assertions#2768
nohwnd wants to merge 1 commit into
mainfrom
improve-new-should-assertion-help

Conversation

@nohwnd

@nohwnd nohwnd commented Jun 27, 2026

Copy link
Copy Markdown
Member

What

Improves the .EXAMPLE blocks (and a couple of explanations) in the comment-based help for the six newer v6 assertions:

  • Should-Invoke / Should-NotInvoke
  • Should-HaveParameter / Should-NotHaveParameter
  • Should-MatchString / Should-NotMatchString

Why

The command-reference pages on pester.dev are generated from this comment-based help, and the examples for these commands had several issues:

  • Should-Invoke / Should-NotInvoke — carried over {... Some Code ...} placeholders from the legacy Assert-MockCalled help, and several examples were missing code fences so they render as escaped text on the site. The Should-NotInvoke explanations were copy-pasted from Should-Invoke and described the opposite behavior (e.g. "throws if ... is not called").
  • Should-HaveParameter / Should-NotHaveParameter — used the old Should -HaveParameter (space) syntax instead of the new Should-HaveParameter; Should-HaveParameter had only one example (no -Type/-DefaultValue/-Alias/-InParameterSet); the Should-NotHaveParameter example showed a failing test and carried an irrelevant -HasArgumentCompleter note.
  • Should-MatchString / Should-NotMatchString — only abstract hello / h.*o samples; replaced with real-life regex checks (GUID, version, secret-leak guard, etc.).

Notes

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

The command-reference pages on pester.dev are generated from this
comment-based help. The examples for the six newer assertions had
several problems, which this fixes:

- Should-Invoke / Should-NotInvoke: replace the {... Some Code ...}
  placeholders and the un-fenced examples (which render as escaped text)
  with real, runnable examples. Fix the Should-NotInvoke explanations,
  which were copied from Should-Invoke and described the opposite
  behavior (e.g. 'throws if ... is not called').
- Should-HaveParameter / Should-NotHaveParameter: use the new
  Should-HaveParameter syntax instead of the old 'Should -HaveParameter';
  add -Type/-DefaultValue/-Alias/-InParameterSet examples; make the
  Should-NotHaveParameter example pass; drop the irrelevant
  ArgumentCompleter note.
- Should-MatchString / Should-NotMatchString: replace the abstract
  hello/h.*o samples with real-life regex checks.

All examples were validated against Pester 6.0.0. Comment-only change.

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