Description
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
if afterEach
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:
- Automatically call
afterEach(cleanup)
ifafterEach
exists. - Add an opt-out mechanism by using
VTL_SKIP_AUTO_CLEANUP
. - Add tests asserting the behavior outlined above.
- Remove
cleanup
references from tests and docs. - Replace cleanup-after-each with a warning (reference).
- State that the change is a breaking change (so that we take it into account when merging!).
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 :)