Skip to content

Split the PesterPreference section into the cases it actually covers - #451

Open
nohwnd wants to merge 1 commit into
mainfrom
nohwnd-pesterpreference-432
Open

Split the PesterPreference section into the cases it actually covers#451
nohwnd wants to merge 1 commit into
mainfrom
nohwnd-pesterpreference-432

Conversation

@nohwnd

@nohwnd nohwnd commented Aug 22, 2026

Copy link
Copy Markdown
Member

Fix #432

The $PesterPreference section was one paragraph covering interactive execution, session defaults and merging with -Configuration all at once, and the only example worked for the first of them. Each now has its own section and its own example.

Adds the part that was missing, which is the thing that confuses people: $PesterPreference set at the top of a test file only applies when you run that file directly. Invoke-Pester ./file.Tests.ps1 ignores it, because the run has already started by the time the file is read.

Also writes down how the merge works, one option at a time:

  • an option set on the configuration object wins
  • an option not set there falls back to $PesterPreference
  • an option set in neither uses its default

Verified against 6.1.0 rather than written from the source: a session-level $PesterPreference with Output.Verbosity = 'Detailed' and Should.ErrorAction = 'Continue', plus a configuration object setting only Output.Verbosity = 'Diagnostic', runs with Diagnostic from the object and Continue from the preference, and leaves the preference object unmodified.

🤖

It was one paragraph covering interactive execution, session defaults and merging
with -Configuration all at once, and the only example worked for the first of them.
Now each has its own section and its own example.

Adds the part that was missing: $PesterPreference set at the top of a test file
only applies when you run that file directly, Invoke-Pester ./file.Tests.ps1
ignores it because the run has already started by the time the file is read.

Also writes down how the merge works, one option at a time: an option set on the
configuration object wins, one that is not set falls back to $PesterPreference, and
one set in neither uses its default.

Fix #432

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

Revise PesterPreference docs

1 participant