In this release there are many fixes and improvements thanks @fflaten to providing most of them!
ANSI colors for output
Output is now printed with colors in AzureDevOps:
To achieve that, Pester detects if the host supports ANSI codes and uses them to output the string. You can control this by this new option:
[PesterConfiguration]::Default.Output.RenderMode
Default Description Value
------- ----------- -----
Auto The mode used to render console output, options are Auto, Ansi, ConsoleColor and Plaintext. Auto
And optionally switch back to classical ConsoleColor, or a new PlainText mode that outputs just text without any embedded formatting.
Check Multiple aliases for Should -HaveParameter
Should -HaveParameter
can now ensure that there are multiple aliases set for a parameter.
function f {
param( [Alias('UserName')] $Name )
$Name
}
Get-Command f | Should -HaveParameter Name -Alias 'n', 'UserName'
InvalidResult:
Line |
1 | Get-Command f | Should -HaveParameter Name -Alias 'n', 'UserName'
| Expected command f to have a parameter Name, with aliases 'n' and 'UserName',
| but it didn't have an alias 'n'.
- Add support for multiple aliases (-Alias) to Should -HaveParameter by @dtewinkel in #2247
Always return to the original path
Pester captures the current path in which Invoke-Pester
is invoked, and returns to this path after the execution of the test, even if the tests change it:
PS C:\projects\myModule> Invoke-Pester -Container (
New-PesterContainer -ScriptBlock {
Describe "d" {
It "i" {
Set-Location C:\Windows
}
}
})
This will return back to C:\projects\myModule
after your tests finish running.
Mocking in Manifest Modules
Mock, Should -Invoke and InModuleScope are now allowed for manifest modules.
Additional changes and improvements
-
Add Should-example for exception-assertion by @fflaten in #2171
-
Fix mocks with enum-parameters and ValidateRange by @fflaten in #2191
-
Don't run Get-CimInstance on Nanoserver by @irishismyname in #2192
-
Exit invoked testfile after interactive execution by @fflaten in #2218
-
Fix hang in New-TestRegistry when access is denied by @fflaten in #2236
-
Add support for assigning lists to StringArrayOption by @fflaten in #2232
-
Throw in Add-ShouldOperator when max number of operators is reached by @fflaten in #2231
-
Validate Should -Invoke is invoked in specified -Scope blocktype by @fflaten in #2230
-
Add -Because to Should -Invoke and -InvokeVerifiable by @fflaten in #2229
-
Fix NRE when assigning null to arrayoption in hashtable by @fflaten in #2219
-
Fix module installation in PowerShell 3 and 4 by @fflaten in #2214
-
Add help for dynamic operator parameters by @fflaten in #2170
-
Support int and double values when merging decimaloption by @fflaten in #2186
-
Update ExpandedPath before executing tests and blocks by @fflaten in #2254
Internal fixes and improvements
- Bump Ubuntu 18.04 to 22.04 in CI test stage by @fflaten in #2252
- Bump macOS 10.15 to 12 in CI test stage by @fflaten in #2253
- Reorg Add-ShouldOperator P-tests to avoid 32 operator limit by @fflaten in #2248
- Update CI build image and PesterTests to .NET 6 by @fflaten in #2249
- Cache nugets in CI by @nohwnd in #2204
- Use latest C# language version by @nohwnd in #2250
- Cleanup remaining testcase param-blocks in tests by @fflaten in #2226
- Use Start plugin-step for TestDrive and TestRegistry PSDrive cleanup by @fflaten in #2237
- Fix support for PowerShell 6.0.4 by @fflaten in #2215
- Sign format files by @nohwnd in #2212
- Replace IsOriginalValue() with IsModified and fix merging and casting of default option values by @fflaten in #2201
- Start interactive execution from BeforeDiscovery by @fflaten in #2217
- Add GitHub Action to run PSScriptAnalyzer on PR and commit by @fflaten in #2221
- Replace alias and positional parameter usage in Coverage.ps1 by @fflaten in #2225
- Add -NoBuild for P-tests by @fflaten in #2200
- Update issue templates to forms syntax by @fflaten in #2176
- Update issue form templates by @fflaten in #2180
- Exclude docs and support files from triggering CI by @fflaten in #2184
- Minor improvements to build script by @fflaten in #2183
- Remove v4 param-blocks from HaveParameter tests by @fflaten in #2224
New Contributors
- @irishismyname made their first contribution in #2192
- @dtewinkel made their first contribution in #2247
Full Changelog: 5.3.3...5.4.0