Skip to content

Weird behaviour - mock hangs when being called twice #2569

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

You must be logged in to vote

Hi. This is by design. The mock isn't called when invoked through Update-SharepointList as it invokes from another state (the module).

You need two mocks for you sample.

  • The one you have to catch the call done directly in the test.
  • Another one specifically for calls made from your module functions

Try adding:

Mock Set-PnPListItem -ModuleName MySharepointModule { 
    # store args into a variable
}

See https://pester.dev/docs/usage/modules

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dandraka
Comment options

Answer selected by dandraka
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