# Unit Test with Code Coverage

**URL:** <https://discourse.nodered.org/t/unit-test-with-code-coverage/36451>\
**Category:** General\
**Created:** [24 November 2020 14:19 UTC](https://discourse.nodered.org/t/unit-test-with-code-coverage/36451 "2020-11-24T14:19:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emanuel](https://avatars.discourse-cdn.com/v4/letter/e/ecc23a/32.png) [@emanuel](https://discourse.nodered.org/u/emanuel)\
**Post date:** [24 November 2020 14:19 UTC](https://discourse.nodered.org/t/unit-test-with-code-coverage/36451/1 "2020-11-24T14:19:51Z")

</div>

I have managed to install mocha and made some unit tests.

I want to check the coverage when running my tests. Is it possible to do with **nyc** (istanbul) for example

I have tried but only get 0% coverage all the time.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 November 2020 14:28 UTC](https://discourse.nodered.org/t/unit-test-with-code-coverage/36451/2 "2020-11-24T14:28:37Z")

</div>

Hi @emanuel - welcome to the forum.

Can you explain a bit more about what you're trying to do and what you have done already? What are you unit testing exactly? A Node-RED flow? a Node? something else?

nyc is a tool for gathering code coverage stats - there are lots of guides for how to use it available online. Without more details about what you have done, its hard to know what to suggest.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 January 2021 14:28 UTC](https://discourse.nodered.org/t/unit-test-with-code-coverage/36451/3 "2021-01-23T14:28:37Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
