Apply Pester.BeforeContainer.ps1 when only discovery runs - #3023
Merged
Conversation
Run.SkipRun returns the discovered tree without executing anything, which is the path the VS Code Test Explorer uses to populate. It goes through Discover-Test, a batch discovery over all containers, and that function never took the BeforeContainer map, so it called Invoke-ContainerDiscovery without -BeforeContainerFile. A file whose discovery depends on the setup discovered fine in a normal run and came back empty when only discovery was requested. Discover-Test now takes the same map the interleaved discover -> run path gets, and resolves it per container, because which files apply depends on where the container is after #2993. Find-Test forwards it too. The per container lookup was written inline in Invoke-Test and is now a function that both paths call, so they cannot drift apart again. That also removes the case-insensitive variable name trap the inline version needed a comment to explain. Fix #3008 🤖
…recontainer # Conflicts: # docs/NEXT-RELEASE.md
See #3026. This PR appending to the shared list is what causes the conflicts. 🤖
This was referenced Sep 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #3008
Run.SkipRunreturns the discovered tree without executing anything, which is the path the VS Code Test Explorer uses to populate. It goes throughDiscover-Test, a batch discovery over all containers, and that function never took theBeforeContainermap, so it calledInvoke-ContainerDiscoverywithout-BeforeContainerFile. A file whose discovery depends on the setup discovered fine in a normal run and came back empty when only discovery was requested.Discover-Testnow takes the same map the interleaved discover -> run path gets, and resolves it per container, because which files apply depends on where the container is after #2993.Find-Testforwards it too.The per container lookup was written inline in
Invoke-Test, and is a function now that both paths call, so they cannot drift apart again. That also removes the case-insensitive variable name trap the inline version needed a comment to explain.Verification
tst/Pester.RSpec.Parallel.ts.ps145/45 in the cascade block, whole file green.tst/Pester.Runtime.ts.ps1andtst/Pester.RSpec.ts.ps1green as well, since this touches shared discovery code.Added a test next to the other cascade tests that asserts
Run.SkipRunand a normal run find the same tests.🤖