Skip to content

Files

Latest commit

 

History

History

__tests__

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 25, 2020
Apr 24, 2020
Feb 25, 2020
Feb 25, 2020
Apr 24, 2020
Feb 25, 2020
Mar 30, 2020
Apr 24, 2020
Apr 24, 2020
Apr 24, 2020
Apr 24, 2020
Mar 30, 2020
Mar 30, 2020
Apr 24, 2020

README.md

React Testing Library notes

Cleanup

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();
  });

Act

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 setStates.