I would like to run all Pester Unit tests locally for a project before pushing my changes back up to GitHub and initializing a Pull Request.
So far I've cloned a project, xFailOverCluster, and installed Pester
and all dependent modules (found using the build-script).
- Pester 5.3.1
.\build.ps1 -Tasks build
- Sampler.GitHubTasks
- Saved DscResources.Common to \output\RequiredModules
.\build.ps1
- DscResource.Test
- DscResource.Analyzer
- DscxDSCResourceDesigner
- PSPKI
- DscResource.Test
- DscResources.Common
I can successfully build the module, using the provided .\build.ps1
script. But the provided Pester Unit tests will all fail.
And when using the more generic Pester Test Explorer
extension in VS Code
, I get the same kind of failures:
Starting discovery in 7 files.
[-] Discovery in D:\UsbRepos\One\xFailOverCluster.GitHub\tests\Unit\MSFT_xCluster.Tests.ps1 failed with: System.IO.FileNotFoundException: The specified module 'xFailOverCluster' was not loaded because no valid module file was found in any module directory.
...
Discovery found 0 tests in 643ms.
...
CodePudding user response:
Ok, turns out it was the build that was at fault on my end (and wrong version of Pester, v4 needed).
Once all dependency modules was in place, I was able to run the Pester tests as invoked by the build.ps1
.
No way of just running Invoke-Pester
though in this project.