Closed codykonior closed 6 years ago
@codykonior I have a branch here that I think addresses this issue: https://github.com/alx9r/Pester/tree/improve-stacktrace-output
Sent with GitHawk
@alx9r Thanks but I think that PR went too far because it didn't realise that the stack trace output is caused by the incorrect regex string. The fix is just adding Invoke-Assertion to the regex string... it doesn't require all that other stuff. What do you think?
1. Provide a general summary of the issue in the Title above
I find that the stack trace output is often too verbose and after some investigation it changed between Pester 3 and Pester 4 and I believe it's due to a missing regex.
In Pester 3:
Results in:
In Pester 4:
Results in:
The difference is the extra Invoke-Assertion line which shouldn't be there. This is because of Output.ps1 and this code:
To rectify this we need a $pattern4 (it should not be put into the other patterns, it does not work this way in $pattern1):
And an updated match statement a few lines down:
That gives you this Pester 4 result which matches the Pester 3 result.
There is a second part to this though because when you run a Gherkin step test it also includes a lot of non-excluded stack trace garbage:
This needs one further pattern added exclude the Gherkin parts and the very last ScriptBlock which seems consistent in every test and caused by the implementation rather than anything useful:
Together with the above Invoke-Assertion pattern, this results in this correct equivalent output for Gherkin tests:
2. Describe Your Environment
Operating System, Pester version and PowerShell version:
6. Context
I'm experimenting with running tests with the idea of running a lot of tests. While you can go to some lengths to pass through the objects and manipulate the output I think that the default output should be kinda sane.