Skip to content

Feature request for 'Should' to output a boolean value #1712

@DarkLite1

Description

@DarkLite1

1. General summary of the issue

Would it be possible for Should to produce a boolean value so it can be used within the script block of -ParameterFilter available on Mock? See the example code below to clarify.

Describe '-ParameterFilter test' {
    BeforeAll {
        Function Test-Colors {
            Param (
                [String[]]$Colors
            )
            $Colors.Contains('Green')
        }

        Mock Test-Colors

        Test-Colors -Colors @('Green', 'Red')
    }
    It "desired functionality" {
        Should -invoke Test-Colors -Scope Describe -ParameterFilter {
            $Colors | Should -Be @('Green', 'Red')
        }
    }
    It "workaround" {
        Should -invoke Test-Colors -Scope Describe -ParameterFilter {
            $Colors | Should -Be @('Green', 'Red')
            $true
        }
    }
}
  1. Possible solution

Maybe it would be great if a switch could be added like:

@('apple', 'kiwi') | Should -Be -OutBoolean @('apple', 'kiwi')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions