I have some quite complex Node Red automations. Being a SW developer, I want automated tests for all my flows so I can make sure things still work OK after I’ve modified them.
My current way of working is adding MQTT inputs to the beginning of my flows, and MQTT outputs at the end of them. Using a python script I then inject MQTT messages and wait for the expected output.
I create inject every x minutes and when it is done if output compared to expected output isn’t expected it will output to debug node and send message via HA to telegram. Also on some nodes I use light-sheduler node.
Yeah, this is not what i am looking for
I want to create a series of tests that can automtically test all my flows and reports an error on the commandline when something fails.
I make a changes to a flow (not in my production environment) and run testcases (from the commandline or GUI) to verify that everything still works like I expect it to work. If all passes, I deploy the flow to my production environment.
The rest just creates flows, clicks in the UI and hopes everything just works?
I haven’t found the need to do that kind of testing. I’m curious as to how complex your flows must be like to make it worth your time to create test cases and have different environments…
I build my flows as smaller parts first, tested in the UI and then I connected them and do a test run of the whole flow if I think I need it. Otherwise I just deploy them as is.
This is also of interest to me. My flows are getting complex and with each update of node-red or HA I feel there may be a breaking change that ends up breaking the automation.
However, I think it’s too hard a problem to solve as what I really need is some feedback from HA to say a light was turned on when asked to - but not sure how to close that loop.
This is probably not ideal but maybe if the logic was all in a function node that opens up all JavaScript test frameworks up for use. Of course, that defeats the main purpose of node-red which is to use the nodes!
As I type this I am also realizing that all node-red exports to JSON so maybe there’s a way to grab the export JSON from node-red and run it through a test.