Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions docs/6.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
> 🙋 Want to share feedback or report a bug? Open an [issue](https://github.com/pester/Pester/issues/new/choose)
> or start a [discussion](https://github.com/pester/Pester/discussions).

This is the first release candidate of Pester 6. It is **feature complete** for 6.0 and meant for
real-world testing before the final release. Pester 6 builds on the v5 runtime (Discovery & Run, the
configuration object, the rich result object) and focuses on a brand new assertion syntax, faster
code coverage, and an experimental parallel runner.
Pester 6.0.0 builds on the v5 runtime (Discovery & Run, the configuration object, the rich result
object) and focuses on a brand new assertion syntax, faster code coverage, and an experimental
parallel runner.

Pester 6 runs on **Windows PowerShell 5.1** and **PowerShell 7.4+**.

Expand Down Expand Up @@ -410,11 +409,51 @@ targets **Windows PowerShell 5.1** and **PowerShell 7.4+**.

- `Assert-MockCalled` and `Assert-VerifiableMock` have been **removed**. Use `Should -Invoke` and
`Should -InvokeVerifiable` (classic syntax) or the new `Should-Invoke` / `Should-NotInvoke`.
- **Mock history** can be printed to help you debug why a parameter filter did or didn't match.
- **Failed `Should -Invoke` assertions print the recorded mock invocation history**, marking which
calls matched your `-ParameterFilter` so you can see why a filter did or didn't match.
- Dynamic parameters are handled more robustly: aliases are matched in `-ParameterFilter`, and
mocking gracefully falls back when a command can't produce dynamic parameters.
- The implicit "fall through to the real command" behavior was removed for more predictable mocks.

#### Mock invocation history

When a `Should -Invoke` (or `Should-Invoke`) assertion fails, Pester now prints the recorded
invocation history for the mocked command — every recorded call, and whether each one matched
your `-ParameterFilter` — so you can see why a filter did or didn't match without adding your own
`Write-Host` debugging. For example, `Order.Tests.ps1`:

```powershell
BeforeAll {
function Send-Email ($To, $Subject) { }
}

Describe 'Order processing' {
It 'emails alice exactly twice' {
Mock Send-Email { }

Send-Email -To 'alice@example.com' -Subject 'Welcome'
Send-Email -To 'bob@example.com' -Subject 'Receipt'

Should -Invoke Send-Email -Times 2 -Exactly -ParameterFilter { $To -eq 'alice@example.com' }
}
}
```

The assertion fails because only one of the two calls matched the filter, and the failure lists
both recorded calls:

```
[-] emails alice exactly twice
Expected Send-Email to be called 2 times exactly, but was called 1 times
Performed invocations:
[*] Send-Email -To 'alice@example.com' -Subject 'Welcome' from Order.Tests.ps1:7
[ ] Send-Email -To 'bob@example.com' -Subject 'Receipt' from Order.Tests.ps1:7
at Should -Invoke Send-Email -Times 2 -Exactly -ParameterFilter { $To -eq 'alice@example.com' }, Order.Tests.ps1:12
```

`[*]` marks a call that matched the parameter filter and `[ ]` marks one that didn't — here
`alice` matched and `bob` didn't, so the matched count is 1 instead of the expected 2.

### Other improvements

- `Run.SkipRemainingOnFailure` (`None`, `Run`, `Container`, `Block`) skips the rest of a scope once a
Expand Down
Loading