-
-
Notifications
You must be signed in to change notification settings - Fork 476
Fix container name in ScriptBlock BeforeAll failures (fixes #2636). #2637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix container name in ScriptBlock BeforeAll failures (fixes #2636). #2637
Conversation
OLD: This PR is still a draft and not yet ready to be merged. There's one test failure that I don't understand. If a maintainer knows the right change here, please feel free to edit.
EDIT: Found the answer; see below. |
I figured out why that one test was failed and made an edit to get it to pass. I think the PR is ready to now. |
Thanks for the PR, can you add more information about the fix, and add a specific test for it? The edit in the current test looks little suspicious, can you explain why it needs to change like this? also putting the Fixes #number directly into the PR description is more helpful, because it will link the PR to the issue, and will close automatically, unlike if you put it in the title 🙂 |
Oh, I thought it worked either way, based on the docs and previous experience: For example, in this case, I think it still linked the issue automatically (see above). Let me know if you want me to change it anyway though. |
400a6e8
to
fd1b9f6
Compare
sure - done |
Sure - here's what this test output would look like for a file:
but here's what it currently looks like for a ScriptBlock:
i.e. it includes the entire code for the ScriptBlock rather than the ScriptBlock's formatted "name". It probably gets really messy if the script block is long. The updated code instead shows it more like a normal file:
Let me know if that helps clarify the motivation for changing the existing test. I think that's net a good change, but let me know if you think otherwise. |
Thanks for the test, is this solving a real issue for you? I don't normally follow the success output, and I don't expect people to run tests from scriptblocks that much. I mostly added that to be able to test pester easily. Do you run tests from scriptblocks? Before: After: I don't see any information lost from failed tests because there we show the failure directly, which is great. |
We give multiple other teams the ability to run Pester tests within another ES, and we support scriptblocks. In the past, when I've guessed there were Pester features other teams wouldn't be using, I've guessed wrong : )
For the failure case, the line with the failure is currently just "[-]", which doesn't identify the name of the file with the ScriptBlock that failed. Displaying that information consistently allows us to integrate it back into our ES's logs. |
fd1b9f6
to
7e763ba
Compare
ok merged into pester 6, do you need those changes in pester 5? |
Thanks, @nohwnd! |
/backport to rel/5.x.x |
Started backporting to rel/5.x.x: https://github.com/pester/Pester/actions/runs/14946881012 |
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.Replace Result.Item with Result.Name to handle the ScriptBlock case. Previously, the container name was being reported only for files, not for ScriptBlocks (because files, unlike ScriptBlocks, have Result.Item).