-
from https://pester.dev/docs/usage/configuration#pesterpreference $PesterPreference = [PesterConfiguration]::Default
$PesterPreference.Debug.WriteDebugMessages = $true
$PesterPreference.Debug.WriteDebugMessagesFrom = "Mock"
BeforeAll {
function a { "hello" }
}
Describe "pester preference" {
It "mocks" {
Mock a { "mock" }
a | Should -Be "mock"
}
}
I then invoke it I then get Why arent the debug outputs showing? EDIT: I found if I DIRECTLY execute the script e.g. I want to in general use the configuration detailed in https://pester.dev/docs/usage/output, but it wont work. heres another test Describe "pester preference" {
It "test 1" {
5 | Should -Be 5
}
It "test2 " {
5 | Should -Be 5
5 | Should -Be 5
5 | Should -Be 5
}
It "test3 " {
5 | Should -Be 5
5 | Should -Be 5
5 | Should -Be 5
}
} Then I set the configuration... Am I doing it wrong somehow?
Starting discovery in 1 files. I would have expected the Diagnostic Level verbosity to show each test , and maybe the "Assert statements" as they execute? My Get-Module -ListAvailable shows
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for reporting this! Right above the first sample it says "while running interactively". Interactive execution means running the script directly without calling
Instead you could use a $conf = New-PesterConfiguration
$conf.Output.Verbosity = "Diagnostic"
$conf.Run.Path = "$PSScriptRoot\mytest2.ps1" # or "$PSScriptRoot/tst" folder ++
Invoke-Pester -Configuration $conf |
Beta Was this translation helpful? Give feedback.
Thanks for reporting this!
Right above the first sample it says "while running interactively". Interactive execution means running the script directly without calling
Invoke-Pester
, typically by pressing F5 in VSCode or ISE. So it's intended behavior, but poorly explained and something we should update 🙂$PesterPreference
is session preferences (like$PSDefaultParameterValues
in PowerShell) and any values has to be set before callingInvoke-Pester
which merges it with any provided parameters. In general I'd recommend to avoid$PesterPreference
unless you want to include a few settings in your profileInstead you could use a
test.ps1
file where you define your configuration and pass it toI…