Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 3.61 KB

12-unit-testing-and-coverage.md

File metadata and controls

47 lines (29 loc) · 3.61 KB

🐢 Node.js

📊 Unit testing and coverage

Performing unit tests is a good way to practice and better understand how X or Y code works (and forces you to study various JavaScript features). Nevertheless it can be difficult to find your way in an ecosystem where the choice of frameworks/libraries is vast:

Mocha, Ava, Jest, Japa, Tape, uvu and a lot of others...

Some will have the advantage of being more complete (heavier) and others more simplistic. Sometimes it comes down to details like the choice of the assertion library (Chai.js for example) or the inclusion of coverage by default.

Warning

The use of Jest for back-end testing is not recommended (poor performance, rewriting of globals, etc.).

When the coverage is not included by default you may have to think about including it yourself with C8 (a lib using the native coverage of V8 Engine). C8 is able to offer coverage even when the code is executed through different child processes (or workers).

Talks and articles:

💃 Méthodologies

Nowadays, it's not uncommon for juniors to be forced to apply methodologies without any real thought or argument from their mentor: "this is how you want to become a good developer".

I think that learning to write tests is essential for a developer (and that it is rather this common foundation that we should build on to guide beginners).

It is important to keep a strong critical mind on the different choices that we will try to impose on you as practices that you must constantly apply because they certainly lock you in an ideological bubble (which is not an invitation to do nothing).

For example, learning TDD and other methodologies will be beneficial to add strings to your ARC (especially on some projects where their practice will be an added value). However, this does not mean that they are absolute to all contexts and projects or that they should not be discussed.

Here are some links to help you make a first "opinion":

In our field we talk very little about this so much that it is subject to extreme tension between us. I sometimes think it's a shame that we can't discuss it without bringing in our own toxicity and ego.


⬅️ 🐢 Node.js: WebSocket | ➡️ 🌟 The different core modules: Console