DEV Community

Cover image for 8 simple steps to start testing React Apps using React Testing Library and Jest

8 simple steps to start testing React Apps using React Testing Library and Jest

Ibrahima Ndaw on March 12, 2020

Testing is frequently seen as something tedious. It's extra code and in some cases, to be honest it's not needed. However, every developer should k...
Collapse
 
hellomeghna profile image
Meggie • Edited

Hi, really loved the article.
Just curious, inside 7th and 8th test files, you've not added afterEach(cleanup), but I think it's a good practice to include it, right?

Also in TestRouter.js, the third <Route>'s path should be /contact:name?

<Route path="/contact:name" component={Contact} />
Collapse
 
sabrinamarkon profile image
Sabrina Markon

If anyone has trouble with the Attribute tests failing, the solution is to
import "@testing-library/jest-dom/extend-expect"
at the top of the test file. I had to do this even though I installed using the cloned repo, so it seemed a comment about it might help someone because this is a fantastic tutorial.
Thank you so much for all your awesome tutorials!

Collapse
 
ibrahima92 profile image
Ibrahima Ndaw

Thank you too for your efforts

Collapse
 
dominikhaid profile image
dominikhaid

Excellent article, good examples and detailed explanation.