Closed gobenaus closed 5 months ago
This happens both on the Windows version of PS (5.1) as well as the open source version: PSVersion 7.3.2 PSEdition Core GitCommitId 7.3.2 OS Microsoft Windows 10.0.19044
Hi. Thanks for the report.
Are you able to provide a minimal repro in an issue @ pester-repo? 🙂
Troubleshooting this require us to see both how the module is designed (manifest-file, nested modules etc) and how the testfile is structured.
Shameless plug for simple issue reproductions https://codesandbox.io/p/sandbox/thirsty-sunset-mj8q9s?file=%2FREADME.md
Are you able to provide a minimal repro in an issue @ pester-repo? 🙂
Troubleshooting this require us to see both how the module is designed (manifest-file, nested modules etc) and how the testfile is structured.
Closing this as missing repo. See comment above if you still experience the issue.
This issue is new with version 5.4. We have a module called Nice.psd1 which has the code defined in Nice.psm1. The module is a folder that is disoverable via the $PSModulePath variable. The unit test file contains the the following statement on startup:
Import-Module Nice -Force
This is to make sure we always have the most recent copy loaded. If this statement is present, we get the following error message on discovery. The tests still seem to run. It doesn't matter if the -force parameter is there or not.
If the statement is NOT present, we get an error complaing that it CANNOT find a module named nice. Some of the tests have the 'InScopeModule 'Nice' statement to be able to call functions that are not exported. This works fine in 5.3.
ERROR WHEN IMPORT STATEMENT IS PRESENT PS C:\Users\Public\Documents\GitRepos\Development\Powershell_Dev\nice\UnitTests> invoke-pester .\Nice.Tests.ps1 -TagFilter 'Get-NiceGlobalSetting' -output Detailed Pester v5.4.0
Starting discovery in 1 files.
Discovery in C:\Users\Public\Documents\GitRepos\Development\Powershell_Dev\nice\UnitTests\Nice.Tests.ps1 failed with: System.Management.Automation.RuntimeException: Multiple script or manifest modules named 'Nice' are currently loaded. Make sure to remove any extra copies of the module from your session before testing. at Get-CompatibleModule, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 10312 at InModuleScope, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 10242 at <ScriptBlock>, C:\Users\Public\Documents\GitRepos\Development\Powershell_Dev\nice\UnitTests\Nice.Tests.ps1: line 53 at New-Block, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 803 at Describe, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 9709 at <ScriptBlock>, C:\Users\Public\Documents\GitRepos\Development\Powershell_Dev\nice\UnitTests\Nice.Tests.ps1: line 48 at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 2995 at Invoke-File, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 3004 at Invoke-BlockContainer, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 2927 at Discover-Test, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 1464 at Invoke-Test, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 2437 at Invoke-Pester<End>, C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1: line 5272 at <ScriptBlock>, <No file>: line 1 Discovery found 12 tests in 1.02s. Filter 'Tag' set to ('Get-NiceGlobalSetting'). Filters selected 12 tests to run. Running tests.