Skip to content
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

feat: call "cleanup" automatically #238

Merged
merged 15 commits into from May 20, 2020
Merged

Conversation

aleclarson
Copy link
Contributor

@aleclarson aleclarson commented Nov 19, 2019

Summary

#234 (comment)
Fixes #234

Taken from here:

https://github.com/testing-library/react-testing-library/blob/14670debd45236d2c5d0a61a83dadc72af1bef7c/src/index.js

Notice how they also flush the microtask queue.

Test plan

None needed?

@aleclarson
Copy link
Contributor Author

In RTL, the cleanup function will flush microtasks once this PR is merged. We should consider doing the same.

@thymikee
Copy link
Member

thymikee commented Dec 4, 2019

Cool, I'll try to get back to this tomorrow :)

@Esemesek Esemesek mentioned this pull request May 18, 2020
10 tasks
# Conflicts:
#	src/index.js
#	yarn.lock
@mdjastrzebski mdjastrzebski changed the base branch from master to next May 20, 2020 08:21
@mdjastrzebski
Copy link
Member

Changes target to next branch (which will be ver. 2.0 master).

@mdjastrzebski mdjastrzebski marked this pull request as draft May 20, 2020 08:36
src/index.js Show resolved Hide resolved
website/docs/API.md Outdated Show resolved Hide resolved
@thymikee thymikee marked this pull request as ready for review May 20, 2020 11:17
@thymikee
Copy link
Member

@mdjastrzebski feel free to merge once you think it's ready :)

@mdjastrzebski mdjastrzebski merged commit 175b9b9 into callstack:next May 20, 2020
thymikee added a commit that referenced this pull request May 28, 2020
* feat: add "cleanup" function

* docs: add "cleanup" section

* feat: automatically call "cleanup" after each test

...if an "afterEach" global function is defined, and process.env.RTL_SKIP_AUTO_CLEANUP is falsy.

Taken from: https://github.com/testing-library/react-testing-library/blob/14670debd45236d2c5d0a61a83dadc72af1bef7c/src/index.js

* docs: mention automatic cleanup

* add within

* fix lint

* Updated tests, added auto-cleanup test

* Added ways to prevent auto cleanup

* Small fix

* Code review changes

* Update website/docs/API.md

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

* More changes

* Removed  afterEach(cleanup) calls in examples

* Code cleanup

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
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 this pull request may close these issues.

Automatic unmount of rendered components at end of each test
3 participants