Guide - JavaScript and React unit tests basics

I’m writing a two-part guide to JavaScript and React unit tests. The guide is aimed at people with some JavaScript experience but that never have written any tests and/or don’t know the concepts.

Since lots of folks here are learning to program and tests are a big part of that I thought of sharing the article here.

The first part covers the concepts and the second will be a tutorial to actually write the tests.

You can find the first part of the guide here.

Let me know if you any comments, feedback is welcome!

1 Like

Hey @lfac-pt.

I just read your tutorial. I think it is very well explained but I want to ask you a question. In FCC curriculum you use Chai and Mocha for testing and you didn’t mention them. Do you think they are not as good as the other libraries you mentioned in the guide?

Thank you very much!

That is a great question.

I’ve used Mocha + Chai professionally for many years and some time ago I’ve changed to Jest. There is nothing fundamentally wrong with Mocha + Chai, and you have all the functionally needed to write unit tests.

The main advantages of Jest for me is that it has a better developer experience than Mocha + Chai and that it has a stronger community behind it.

I would argue that for a beginner Jest is actually a better option because it usually requires no setup.

Hope this helps!