Pester – It block doesn’t recognise function outside block.

Welcome Forums Pester Pester – It block doesn’t recognise function outside block.

Viewing 4 reply threads
  • Author
    Posts
    • #272203
      Participant
      Topics: 2
      Replies: 3
      Points: 31
      Rank: Member

      So I have this function at the script scope level.

      Error I am getting on run:

    • #272212
      Senior Moderator
      Topics: 9
      Replies: 1411
      Points: 5,240
      Helping Hand
      Rank: Community MVP

      In which file is the function defined and what is the pester version you are using ?

    • #272233
      Participant
      Topics: 2
      Replies: 3
      Points: 31
      Rank: Member

      Hi Kvprasoon, I am using Pester 5.0 and Powershell 7.1.
      The function is in the same script as the test. Here is the full script with the rest of the tests and multiple entries to the arrays cut out:

      • This reply was modified 1 week, 1 day ago by Wandarah60. Reason: cleaned up some typos
      • This reply was modified 1 week, 1 day ago by Wandarah60.
    • #272299
      Senior Moderator
      Topics: 9
      Replies: 1411
      Points: 5,240
      Helping Hand
      Rank: Community MVP

      Pester v 5.x has significant changes from previous versions and your problem can be solved by re arranging the code. Please read https://github.com/pester/pester#discovery–run to understand more on the changes which is causing you the trouble.

    • #272341
      Participant
      Topics: 2
      Replies: 3
      Points: 31
      Rank: Member

      Pester v 5.x has significant changes from previous versions and your problem can be solved by re arranging the code. Please read https://github.com/pester/pester#discovery–run to understand more on the changes which is causing you the trouble.

      Thnx Kvprasoon, dumping everything into a large BeforeAll {} block except for the tests solved my issue. I’m new to coding, its a new concept for me to have a BeforeAll {} scriptblock.

Viewing 4 reply threads
  • The topic ‘Pester – It block doesn’t recognise function outside block.’ is closed to new replies.