node-red / node-red-node-test-helper

A test framework for Node-RED nodes
Apache License 2.0
57 stars 41 forks source link

In Node-RED 1.x using helper.log().args doesn't show Errors #41

Closed natcl closed 4 years ago

natcl commented 4 years ago

My node throws an error and with Node-RED 0.20.x I used to be able to get that error in helper.log().args. In Node-RED 1.x the error doesn't seem to be in the array anymore. I created a small repo based on the lower-case example to demonstrate this issue, to test you can do the following:

# Works:
git clone git@github.com:natcl/lower-case-fail.git
cd lower-case-fail
npm install
npm test

# Fails:
git checkout origin/nr1fail
npm install
npm test
natcl commented 4 years ago

Update: seems like wrapping the call containing helper.log().args into a setTimeout solves the issue.

dceejay commented 4 years ago

how about a setImmediate ? (ie just just push it to next loop ?)

natcl commented 4 years ago

I'll test that, (the core nodes seem to use setTimeout with different timing values though, I checked the JSON node test specifically)

natcl commented 4 years ago

Just tested and setImmediate works fine in my case too. Thanks !