Skip to content

[Startup MVP recipes #12] Nest.js Unit Testing: Test Coverage

This is the one more little bonus article on how to leverage existing test coverage tools to improve unit tests drafting and get easier and deeper insights.

To learn more about test coverage check

The Setup in Nest.js

Instructions of configuring Jest are in–string-options

// package.json

	// ...
  "test:cov": "jest --coverage",
  "test:local:cov": "NODE_ENV=local jest --coverage",

// within jest config section
"jest": {
  "coverageDirectory": "../coverage",
  "coverageReporters": [


To get the coverage run the following command and in console output we can get the text summary

npm run test:cov

Now we can go to the coverage/ folder to check the visualized test coverage in the html files. Click on html and you can start use it:

Leave a Reply

Your email address will not be published. Required fields are marked *