DEV Community

Discussion on: Writing unit tests with React, Typescript, and react-testing-library

Collapse
 
simme profile image
Simme • Edited

How about using describes and beforeEach's? That would probably be a more idiomatic approach to accomplish the same things. If you find the need to rerender stuff too often, you're probably combining what should be multiple tests.

Collapse
 
pclundaahl profile image
Patrick Charles-Lundaahl

I'd +1 this.

Not that I don't enjoy the type gymnastics that are going on in the article (I'm a really big fan of TS's structural typing, and I spend way more time than I should doing similar things in my side projects). I just think this could probably be simpler by better leveraging your testing library.