DEV Community

pgangwani
pgangwani

Posted on

Which tool/s do you use to test react projects and why ?

This is a discussion.

Which toolset you use in your react projects for unit test, code coverage and e2e test and why ?

Did you ever face a serious problem which made you think to switch other option/alternative?
If yes, what did you do ?

Have you ever went deep into the module and contributed for new issue which nobody else logged (like creating an issue and pull request for it) ?

Please share your experiences. Let's go dev.to learn and share.

Top comments (2)

Collapse
 
shikaan profile image
Manuel Spagnolo

1) Unit test (no-render components): mocha/titef
2) Unit tests (render components): jest + enzyme
3) Integration tests: jest + enzyme
4) E2E: wdio (with mocha)

I am the author of titef*, so 1) can be biased. In 2) I am taking in account snapshot testing. In 3) I am talking about integration between components.

Excluding titef, I'd use mocha for pretty much everything, but snapshots are extremely convenient, especially when you need to deliver fast. Bottom line, my decision tree goes pretty much like:

  • small project, mostly visual, no much logic -> jest + enzyme and mostly snapshot tests
  • small project, lots of logic, dumb or not-so-relevant UI -> mocha (+ enzyme eventually) and mostly unit tests
  • medium project worth a double setup -> mocha, jest + enzyme and unit tests with snapshots
  • big project -> all the above

*: The reason why I started titef was that jest is incredibly slow, but I love snapshot testing. I didn't finish it yet, so right now it's just a faster mocha.

Collapse
 
pgangwani profile image
pgangwani

Interesting.