Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/commands/Add-ShouldOperator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/AfterAll.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/AfterEach.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/BeforeAll.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/BeforeDiscovery.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/BeforeEach.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/Context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/ConvertTo-JUnitReport.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/ConvertTo-NUnitReport.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/ConvertTo-Pester4Result.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/Describe.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/Export-JUnitReport.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/Export-NUnitReport.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/Get-ShouldOperator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ standard PowerShell discovery patterns (like `Get-Help Should -Parameter *`).

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/InModuleScope.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/Invoke-Pester.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/It.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
43 changes: 42 additions & 1 deletion docs/commands/Mock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,38 @@ Describe "ModuleMockExample" {
This example shows how calls to commands made from inside a module can be
mocked by using the -ModuleName parameter.

### EXAMPLE 10

```powershell
Describe "Get-Date wrapper" {
BeforeAll {
# Capture the original command before it is mocked, so it can be
# called from inside the mock. Use -CommandType Function, Cmdlet or
# Application to match how the original command is implemented.
$originalGetDate = Get-Command Get-Date -CommandType Cmdlet
}

It "prefixes the original date output" {
Mock Get-Date {
# Invoke the original command, forwarding the bound parameters
# that were passed to the mocked command.
$date = & $originalGetDate @PesterBoundParameters
"DATE: $date"
}

Get-Date -Date '2000-01-01' -Format 'yyyy-MM-dd' | Should -Be 'DATE: 2000-01-01'
}
}
```

Sometimes you want to mock a command but still run the original
implementation, for example to wrap or inspect its output.
Capture the
original command with Get-Command in a BeforeAll before the mock is defined,
then invoke it inside the MockWith script block using the call operator (&).
Forward the caller's arguments with @PesterBoundParameters, a hashtable of
the parameters that were bound on the mocked command.

## PARAMETERS

### -CommandName
Expand All @@ -209,6 +241,11 @@ NOTE: Do not specify param or dynamicparam blocks in this script block.
These will be injected automatically based on the signature of the command
being mocked, and the MockWith script block can contain references to the
mocked commands parameter variables.
The parameters bound on the mocked
command are also available as a hashtable in the $PesterBoundParameters
variable, which is convenient for forwarding them to another command.
See
the examples for calling the original command from inside the mock.

```yaml
Type: ScriptBlock
Expand Down Expand Up @@ -267,6 +304,10 @@ is to be mocked.
This should be a module that _calls_ the mocked
command; it doesn't necessarily have to be the same module which
originally implemented the command.
When the experimental Mock.Global
configuration option is enabled this parameter is used only as a hint to
resolve the command (for example to find a module-private command), not
to scope where the mock applies.

```yaml
Type: String
Expand Down Expand Up @@ -338,4 +379,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/New-Fixture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/New-MockObject.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/New-PesterConfiguration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
2 changes: 1 addition & 1 deletion docs/commands/New-PesterContainer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## VERSION

*This page was generated using comment-based help in [Pester 6.0.0-rc5](https://github.com/pester/pester).*
*This page was generated using comment-based help in [Pester 6.1.0](https://github.com/pester/pester).*
Loading