I am testing my self-made PS module and when the PS module gets imported, there is a script that gets dot-sourced to setup the environment prior to loading the module. There is a variable that gets defined during the environment set up and gets utilized in one of my functions within the module.
Now with that explained, when I run my Pester test, I can see that the variable is null due to my verbose logging even though my verbose logging shows that the script is dot-sourced and loaded prior to executing the test.
Now if I set the variable to a Global variable, then my test works because the variable is now defined. I do not want to setup my variable to a Global scope if it is not necessary.
Any suggestions on what I need to do to prevent from changing my variable to a Global defined variable or best practice?