Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly test node-red nodes?

I'm developing a node-red node, and I'd like to know the best or intended way to test those nodes. I've been looking at some other nodes, and they look to depend on a peer installation of node-red itself and use the "helper.js" to load those nodes. I was expecting to have a more "unit-level" testing perhaps mocking the node-red.

like image 631
Diego Pamio Avatar asked Jul 05 '16 15:07

Diego Pamio


People also ask

How do you inject node nodes in red?

The Inject node can be used to manual trigger a flow by clicking the node's button within the editor. It can also be used to automatically trigger flows at regular intervals. The message sent by the Inject node can have its payload and topic properties set.

CAN Node-RED be used in production?

This allows to securely deploy flows from the lab to the real world into production. And yes, Node-RED is stable enough to run in production (and qbee is governing it while doing so). It is also possible to distribute the flows through the APIs and online services such as GitHub.

How do I stop my nodes from running red?

As with running Node-RED locally, you can use the node-red command to run Node-RED in a terminal. It can then be stopped by pressing Ctrl-C or by closing the terminal window.


1 Answers

If you look at the way that the core nodes are tested, this should give you some ideas.

There is also an effort underway to extract the test harness from core and make it available for everyone. You should also check out the Node-RED WIKI which contains some information on testing.

In general, it looks like you will need to run your node in an embedded version of Node-RED. Running NR using your chosen test tool.

like image 153
Julian Knight Avatar answered Sep 19 '22 13:09

Julian Knight