Pester: Is it possible to test output of other streams?

Looking for ways to test execution flow in my unit tests without asserting anything from the standard output stream. In other words, I’d like to be able to assert things from other output streams, such as the Information stream and the Warning stream. Is this possible?

Any ideas on how this could be done?

Not sure if this fits your need, but have you looked into stream redirection?

describe 'Test redirected streams' {

    It 'Warning stream should output warning message' {
        Write-Warning 'Warning message' 3>&1 | Should Be 'Warning message'


Read more about redirection of streams in the Hey, Scripting Guy Understanding Streams, Redirection, and Write-Host in PowerShell by June Blender, and the about_Redirection help topic

Perfect. This is exactly what I was looking for.

Appreciate you taking the time to respond. Thanks for the additional links as well.

Glad you found it useful :slight_smile: