-
-
Notifications
You must be signed in to change notification settings - Fork 473
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
TestDrive behaves like Context in nested Describe #1837
Comments
This is by design. TestDrive is setup only for the top-level block, be it Describe or Context and re-used all the way down. Describe and Context are interchangeable 99% of the time, except for Mock -Scope Describe vs Mock -Scope Context. So in this case it does not matter if you put Context in Describe or Describe in Context. It will setup TestDrive only for the top-level block. |
Understood, thanks for your time. In that case, I see two sub-issues from this:
What are your thoughts? |
@Axiometry I will stick with the current behavior. The proposed behavior sounds nice for some cases, but would be complicated to implement, full of edge cases, and file copying. And because TestDrive is a PSDrive, talking with it is not the fastest. Additionally it should also work the same way for TestRegistry. So there is a lot of thinking to be done, and backwards compatibility. If you want to PR it I will by happy to review you code and help you steer it, but can't commit to implementing it myself. If you need a clean test drive for a block, I would suggest you add BeforeAll and create a directory in the TestDrive and give it a random name, and save that path into a variable, and use that in your tests. |
@Axiometry See updated Scoping-docs for Testdrive, https://pester-docs.netlify.app/docs/usage/testdrive Is it clearer now? |
Closing as won't fix. TestDrive is created per container and creating subfolders is a good solution for this. See nohwnd's suggestion and docs. |
General summary of the issue
I nested a Describe block in another Describe block, with the intention of having a new TestDrive set up for the nested Describe block (while leaving the main Describe block's TestDrive intact). However, what I found was that the nested Describe block was given the same TestDrive folder as the main Describe block. I also observed the rest of the behavior usually associated with Context blocks, as described here: https://pester-docs.netlify.app/docs/usage/testdrive
Describe your environment
Steps to reproduce
Expected Behavior
The documentation doesn't state that a nested Describe block functions like a Context block. As a result, I expected a nested Describe block to function just like a top-level Describe block.
Specifically:
Example of output from above, if it worked as I'd expect:
Current Behavior
Possible Solution? (optional)
The text was updated successfully, but these errors were encountered: