Skip to content

Cleanup done automatically for Jest/Mocha/Jasmine (according to docs) #12

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

Closed
jamiecoe opened this issue Nov 6, 2019 · 3 comments · Fixed by #13
Closed

Cleanup done automatically for Jest/Mocha/Jasmine (according to docs) #12

jamiecoe opened this issue Nov 6, 2019 · 3 comments · Fixed by #13

Comments

@jamiecoe
Copy link
Contributor

jamiecoe commented Nov 6, 2019

Apparently cleanup() is done automatically if the testing framework you're using supports the afterEach global (like mocha, Jest, and Jasmine):

https://testing-library.com/docs/react-testing-library/api#cleanup

Would this make the following section of the README unnecessary?

Note:

If you read the docs for render you'll see that it's recommended to be used with the cleanup function. This will ensure you don't end up with lots of copies of your component in the same document.

You can use Jest's handy method that runs after each test to do this: afterEach(cleanup).
@oliverjam
Copy link
Owner

oliverjam commented Nov 7, 2019

Huh that's new, sweet. Thanks for finding that! Want to do a PR to remove that section?

@jamiecoe
Copy link
Contributor Author

No probs! Will make PR 👍

@oliverjam
Copy link
Owner

Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants