Hi,
I'm using Pester to test code in a script that calls a function in a second script. I'm dot-sourcing the second script before calling Invoke-Pester, but its functions aren't in scope when Pester runs the tests for the first script. I gather they're in script scope, and aren't accessible from the scope of the Pester module.
In case it's not clear there's a sample here:
Everything works if I run the tests from within PowerShell ISE because it sources the functions into the global scope. But I'd like to be able to run them from a CI job command line.
In the real application I have a number of .ps1 files dot-sourced from the main program and from the unit test driver script. Some functions, like logging functions, are called from other libraries and it would be painful to mock out the calls for every test, or to duplicate dot-source the logging .ps1 from every library .ps1 that requires it. I'm wondering what others are doing in similar situations.
Thanks,
Mike