You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write tests for the new Dashboard 2.0. In doing so, I have a passthru option, which when disabled, does not send a message on to any connected nodes.
As such, I needed to write a test that check the sinon.spy() on node.send()did not run. However, it does.
Upon investigation with @knolleary, we discovered that all nodes in the helper share a single spy on the respective .send(), this means that any node sending a message would trigger this spy, thus making it impossible to register whether or not the node.send() was not run for a given node we cared about.
Temporary Workaround
In order to circumnavigate the issue, we have used the following pattern utilising setTimeouts and.a helper-node:
Wire the node we want to watch to a helper-node (Helper 1)
Add a complete node with a scope set the node id of the node we care about
Wire a helper-node (Helper 2) after the complete node as we can't monitor on('input') for `complete nodes.
Define a msgSent = false in the scope of the test
Add an on('input') for Helper 2 and within it, set the variable msgSent to true
Add an on('input') for the helper node after the complete.
Inside this event handler, set a timeout (e.g. 50ms) to ensure that Helper 2 handles logic first, then check that msgSent is true/false, depending on the desired outcome of the test
The text was updated successfully, but these errors were encountered:
Problem Summary
I'm trying to write tests for the new Dashboard 2.0. In doing so, I have a
passthru
option, which when disabled, does not send a message on to any connected nodes.As such, I needed to write a test that check the
sinon.spy()
onnode.send()
did not run. However, it does.Upon investigation with @knolleary, we discovered that all nodes in the helper share a single
spy
on the respective.send()
, this means that any node sending a message would trigger this spy, thus making it impossible to register whether or not thenode.send()
was not run for a given node we cared about.Temporary Workaround
In order to circumnavigate the issue, we have used the following pattern utilising setTimeouts and.a
helper-node
:helper-node
(Helper 1)complete
node with ascope
set the node id of the node we care abouthelper-node
(Helper 2) after thecomplete
node as we can't monitoron('input')
for `complete nodes.msgSent = false
in the scope of the teston('input')
for Helper 2 and within it, set the variablemsgSent
totrue
on('input')
for thehelper
node after thecomplete
.msgSent
istrue
/false
, depending on the desired outcome of the testThe text was updated successfully, but these errors were encountered: