Exception calling "LeaveTestGroup" with "2" argument(s): "TestGroups stack corrupted: Expected name/hint of '$name','$hint'.. Found '[context]','Context'." $pester.LeaveTestGroup($testScript.Path, 'Script')
This is caused when your function is calling “exit” while testing. Or at least it did in my case. Properly mock whatever is calling exit or find a way to not use exit! Look at the source code here for hints as to what is actually happening. Pester makes sure it is still in the context it started as before leaving a test group. If you call exit this test fails and an exception is thrown.