Closed jazuntee closed 1 year ago
Thanks for the report. This is the same issue as #2073.
A workaround for now is to call New-PesterContainer
once per path with it's own copy of the hash table.
$containers = $ModuleTestsDirectoryInfo | % { New-PesterContainer -Path $_.FullName -Data @{ ModulePath = $ModuleManifestFileInfo.FullName } }
$PesterConfiguration.Run.Container = $containers
Checklist
What is the issue?
When invoking Pester configuration with multiple test scripts, adding a script parameter to one of the test scripts (that does not exist on the others) throws the following error during discovery on all other test scripts loaded AFTER the script containing that new parameter.
Expected Behavior
I expected all other test scripts to be unaffected by the new parameter in one of the test scripts.
Invoking Pester Configuration with Data parameter containing value for the named parameter, would be mapped to the one script containing that parameter and ignored for all test scripts that did not contain that script parameter.
Likewise, Invoking Pester Configuration with Data parameter NOT containing a value for script parameter would result in default script parameter value in the test script containing that parameter and no issue with scripts that do not.
Steps To Reproduce
TestScript1.ps1
TestScript2.ps1 (Contains Unique ModulePrefix Parameter)
TestScript3.ps1
TestScript4.ps1
Invoke Pester Configuration
Discovery on TestScript3.ps1 and TestScript4.ps1 throws error because they followed TestScript2.ps1 which contained a parameter that does not exist on TestScript3.ps1 and TestScript4.ps1.
Describe your environment
Pester version : 5.4.0 C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.0\Pester.psm1 PowerShell version : 7.3.2 OS version : Microsoft Windows NT 10.0.22621.0
Possible Solution?
No response