-
Notifications
You must be signed in to change notification settings - Fork 111
Automatically cleanup if afterEach is detected #77
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
Comments
Can I jump on this |
Sure, go for it! 😊
|
@afontcu can you please help me clarify some things.
|
Hi! Sure! The idea is to follow React Testing Library steps, so their Pull Request is gonna be really helpful.
I'd suggest going over that merged PR and trying to understand how are they handling the auto-cleanup. |
Currently going through the merged PR. I hope to send a PR when I get it all figure. |
great :) feel free to create a draft PR so we can discuss things over code. |
#80 have solved the first two concerns I think? |
@Oluwasetemi yes, looks great! :) Next step is testing it out, and also I would add some comments explaining the feature. Something like the following:
|
@Oluwasetemi perfect! I've added a few comments. Next steps:
Thank you! 🤗 It's looking really good. |
I have updated the PR |
You can disable this with the VTL_SKIP_CLEANUP environment variable, but it's recommended to have cleanup work this way. Closes #77 BREAKING CHANGE: If your tests were not isolated before (and you referenced the same component between tests) then this change will break your tests. You should keep your tests isolated, but if you're unable/unwilling to do that right away, then you can run your tests with the environment variable VTL_SKIP_AUTO_CLEANUP set to true.
🎉 This issue has been resolved in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Right now, users need to call
afterEach(cleanup)
or configure Jest to do so. This makes sure test run in isolation, but requires manual action.As React Testing Library just did, we should probably automatically call
cleanup
ifafterEach
method exists.RTL ended up offering two opt-out mechanisms (via custom import or using an env variable), but I'm not sure this is totally needed. I would keep the env variable (
VTL_SKIP_AUTO_CLEANUP
), but still have a single import point (instead of creating that "pure" version on VTL). Not a big deal, though.So a PR (or several PRs) should:
afterEach(cleanup)
ifafterEach
exists.VTL_SKIP_AUTO_CLEANUP
.cleanup
references from tests and docs.After that, we'd need to update the official docs.
I'm marking this as a good first issue since details are outlined and the referenced PR from RTL makes a great starting point :)
The text was updated successfully, but these errors were encountered: