wayfair-archive / awesome-learning-exercises

Awesome Learning Exercises - the source code for the Awesome Learning platform.
https://wayfair.github.io/awesome-learning/
BSD 2-Clause "Simplified" License
15 stars 19 forks source link

React Testing Library tests aren't cleaning up DOM #49

Closed helloitsjoe closed 4 years ago

helloitsjoe commented 4 years ago

React Testing Library isn't automatically cleaning up after itself, so multiple elements with the same properties are found in the DOM, causing tests to fail.

To fix: Add this to each test file (including this in setup.js file doesn't seem to work):

import { render, cleanup } from '@testing-library/react';

beforeEach(cleanup);