Improving your testing code coverage in Javascript

Marcos Henrique da Silva
17 min readNov 17, 2021

Actually, in Typescript. It’s 2021, you should be using it already, period.

Hello everyone, welcome back! And as usual, source code in the end of the article!

Photo by ThisIsEngineering from Pexels

In this article I am aiming to write a bit about unit testing, specifically targeting testing coverage. It is supposed that you are a beginner to intermediary level with Node.JS and knowing basics of Typescript and any common Node.JS framework. I will be specifically talking about NestJS and their Jest integration. You can take the ideas from this article and adapt to your project in a case that you are using a different framework.

Why Typescript?

Typescript is commonly used in consolidate enterprise companies and it works really well when you are working in a mixed team full of juniors/mid/seniors. It allows you to guarantee some code standards that sometimes using pure Javascript might get easier to bypass some quality gates. If you need any introduction to setup your Typescript project, please read my tutorial.

The majority of frameworks that you use already supports Typescript by default, and usually they already have Typescript configured. Typescript also make it easy to apply SOLID principles. Rather if you like Typescript or hate it, it is also a common job interview question “How

--

--

Responses (2)