# Testing a node, where is the error output?

**URL:** <https://discourse.nodered.org/t/testing-a-node-where-is-the-error-output/39371>\
**Category:** Developing Nodes\
**Created:** [19 January 2021 08:22 UTC](https://discourse.nodered.org/t/testing-a-node-where-is-the-error-output/39371 "2021-01-19T08:22:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sander76](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sander76/32/35508_2.png) [@sander76](https://discourse.nodered.org/u/sander76)\
**Post date:** [19 January 2021 08:22 UTC](https://discourse.nodered.org/t/testing-a-node-where-is-the-error-output/39371/1 "2021-01-19T08:22:02Z")

</div>

Getting started with testing my created Node (coming from Python). I have followed the testing tutorial ([Creating your first node : Node-RED](https://nodered.org/docs/creating-nodes/first-node#unit-testing)) and got it working.

However, I now have a test that fails. But the only message I get is a timeout error:

```auto
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\Users\sander\repos\squid_nodes\test\data_spec.js)

```

I assume my node is causing a kind of exception, which is not caught and as a result exits the test before `done()` can be called.

But where can I find the exception info ? That would be the part I need to solve my issue I guess.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 January 2021 21:36 UTC](https://discourse.nodered.org/t/testing-a-node-where-is-the-error-output/39371/2 "2021-01-19T21:36:41Z")

</div>

Does the test exercise one small part of your node? If you aren't getting any useful output there are a couple of things you can do.

1. stick `console.log` messages librerally through the section of code you are testing and see which message is the last one you get.
2. Run Node-RED under a debugger such as the one built into VScode. Then you can put a break statement into the start of the code under test and walk through the code in the debugger.

---

<div class="post-metadata">

**Author:** ![sander76](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sander76/32/35508_2.png) [@sander76](https://discourse.nodered.org/u/sander76)\
**Post date:** [20 January 2021 19:55 UTC](https://discourse.nodered.org/t/testing-a-node-where-is-the-error-output/39371/3 "2021-01-20T19:55:54Z")

</div>

Oh man, You just saved my day on point 2 ! (I found out point1 myself in the end).  
In `package.json`, just above the test script there appears a "debug" button in vscode. Just hit it and you're off !

Many thanks !

---

<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:** [3 February 2021 19:55 UTC](https://discourse.nodered.org/t/testing-a-node-where-is-the-error-output/39371/4 "2021-02-03T19:55:54Z")

</div>

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