Skip to content

How do you pass an entire array to an It block? #2131

Answered by fflaten
codykonior asked this question in Q&A
Discussion options

You must be logged in to vote

You won't get empty items with (,$files), just an array with the files-array as first and only time.

It "Blah" -ForEach (, $files) {
    # Executes once with $_ equal to the original $files
}

You could also use a hashtable as a wrapper. Each key will be available as a named variable in the test.

It "Blah" -ForEach @{files = $files} {
    # executes once. $files (key) contains the array. $_ contains the hashtable 
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nohwnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants