Skip to content

4 -> 5: my tested module doesn't seem to be imported #2402

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

You must be logged in to vote

In Pester v5 the setup code can't be loosely placed inside Describe/Context. You need to place it inside a BeforeAll or BeforeEach-block.

See first section in the migration guide

Try this:

#requires -Module F7History

Describe "f7_history" {
    Context "The f7_history function" {
        BeforeAll {
            $cmd = $null
            try {
                $cmd = get-item -path Function:\f7_history
            } catch {
               $cmd = $null
            }
        }
        
        It " is defined" {
            $cmd | Should -Be "f7_history"
        }
    }
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by tig
Comment options

You must be logged in to vote
0 replies
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