Skip to content
ConsoleMonster
Cmdlet

Assert-ConsoleOutput

Module ConsoleMonster
Inputs
System.Object
Outputs
System.String

Compares console output with a golden file (for Pester and other tests).

Syntax

Assert-ConsoleOutput [-Culture <CultureInfo>] [-Glyphs <Ascii|Basic|Full>] [-GoldenPath] <String> [-Height <Int32>] [-InputObject] <Object> [-PassThru] [-Width <Int32>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Compares console output with a golden file (for Pester and other tests).

Renders a widget at a fixed width, glyph tier and culture (invariant by default), so the result does not depend on the machine, and compares the text with a golden file. The first run writes the file and fails so it can be reviewed; a difference fails with the first differing line, both versions and the column where they part. Set CONSOLEMONSTER_UPDATE_GOLDEN=1 to rewrite golden files after an intended change. Strings are compared as they are. In Pester the thrown error fails the test; see the README for a Should operator built on it.

Examples

Authored help example

EXAMPLE 1

Assert-ConsoleOutput -InputObject 'Value' -GoldenPath 'C:\Path'

Parameters

-Culture CultureInfo optional
The culture for numbers and dates (default: invariant).
-Glyphs GlyphTier optional
The glyph tier (default Full).
Possible values: Ascii, Basic, Full
-GoldenPath String requiredposition: 1
The golden file.
-Height Int32 optional
Height in cells (default: as tall as the widget measures).
-InputObject Object requiredposition: 0pipeline: True (ByValue)
A widget, or text to compare as it is.
-PassThru SwitchParameter optional
Writes the rendered text to the pipeline when it matches.
-Width Int32 optional
Width in cells (default 80).

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.