#Can you override module variables in Pester?

4 messages · Page 1 of 1 (latest)

digital gyro
#

Assume I have a variable $ConfigPath in mymodule.psm1 and cmdlet Get-MyConfig uses that variable to fetch the data from the configuration file.

Can I run a test and override that variable so I that I perform the operations on a test file instead of the real configuration file that could affect the software it is used by?

void summit
#
& (gmo modulename) { $configpath = 'x' }
digital gyro
void summit
#

It runs the scriptblock in the modules state. It allows you to modify variables among other things.