Question · JavaScript and React course · Module 13: Testing React

Automatic cleanup in RTL

What does the cleanup() function in React Testing Library do, and when is it called automatically?

Answer options

  • It unmounts components from the DOM after each test - @testing-library/react calls it automatically
  • It clears the browser cache - never automatic
  • It deletes the test files after the run - called manually
  • It resets the Redux store state - called in beforeAll

You can check the correct answer by solving this task in the CodeWorlds game.