Currently we are using @testing-library/react/pure
instead of @testing-library/react
since our tests are not isolated.
On writing new tests, please keep the cleanup
functions in separate repeating or one-time functions like afterEach
or afterAll
.
Otherwise, it will lose the scope of the document
, and it won't be able to clear the body
.
BAD
afterAll(() => {
cleanup();
clock.restore();
clearIntervalSpy.restore();
});
GOOD
afterAll(cleanup);
afterAll(() => {
clock.restore();
clearIntervalSpy.restore();
});
Ignore the warnings about act and do not wrap state mutations inside it. It is a useful helper for vanilla React state but it creates falsely passing tests for React Easy State - as it batches setState
s.