Testing a node, where is the error output?

Getting started with testing my created Node (coming from Python). I have followed the testing tutorial (Creating your first node : Node-RED) and got it working.

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

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.

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.

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 !

1 Like

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