Expected path System.Collections.Hashtable to exist, but it did not exist. #2422
-
| 
         Hey all, Looking for some guidance or a solution. I'm a bit stuck. My test seems to work fine but it seems to give this error even though my tests pass. I'm using Pester v5 in an Azure DevOps pipeline with a PowerShell task. I'm essentially collecting all files in a specific path, then joining these to create an array with a list of file paths to run a 'Test-Path' / Should -Exist test. My test: It is running the tests successfully. It's like it's adding an extra  What am I missing here? Thank you!  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| 
         Hi.  To avoid the null-element, you can either: 
     $testFiles = foreach ($moduleFile in $moduleFiles) {
        Join-Path $testPath ($moduleFile.BaseName + '.tests.bicep')
    } | 
  
Beta Was this translation helpful? Give feedback.
Hi.
$testFiles = @($testFiles) + @($testFile)adds a null-element at the start of your array due to$testFilesbeing undefined on the first foreach-iteration. The test generated for the$null-element has$_set to an empty hashtable atm. Related #2320.To avoid the null-element, you can either:
$testFiles = @()before the loop