The code in lines 11-13 of PesterThrow.ps1 (https://github.com/pester/Pester/blob/Beta/Functions/Assertions/PesterThrow.ps1#L11-L13) fails to redirect output to $null when testing PowerShell DSC exception handling. This subsequently causes the output to enter the pipeline and possibly break the test. Also, when a DSC exception is thrown by the user, multiple ErrorRecord objects are sent to the pipeline; a RuntimeException, which represents the user generated throw as well as a FailToProcessConfiguration exception that DSC throws. This prevents Pester from evaluating whether or not the exception's message is as asserted.
My proposal is to redirect all output to $null using *> $null.
The code in lines 11-13 of
PesterThrow.ps1(https://github.com/pester/Pester/blob/Beta/Functions/Assertions/PesterThrow.ps1#L11-L13) fails to redirect output to$nullwhen testing PowerShell DSC exception handling. This subsequently causes the output to enter the pipeline and possibly break the test. Also, when a DSC exception is thrown by the user, multiple ErrorRecord objects are sent to the pipeline; aRuntimeException, which represents the user generated throw as well as aFailToProcessConfigurationexception that DSC throws. This prevents Pester from evaluating whether or not the exception's message is as asserted.My proposal is to redirect all output to
$nullusing*> $null.