Trying to automate my testing, with "npm test" scripts, github and Travis-ci. Works fine for the most part, but I somehow cannot get the flow to work and catch output from the verisurenode, that is supposed to fetch data from verisure apis. I'm using mocha to intercept and answer the api calls. I can confirm that the node receives an incoming message, but troubleshooting after that is hard. Bit of newbie on the testing part...
No one with experience in using test-helper? Seems now my main issue that using .emit() doesnt actually make anything being sent on to the next node...
Test helper is used extensively by the core nodes, and has evolved as the testing requirements of those nodes have evolved. But it isn't used much (yet) out side of that. So there is limited experience in the community for using it.
The best I can suggest is to follow the examples in the core node tests.
When you stay using .emit doesn't do anything... Can you elaborate? I don't see it being used in you code here.
You are calling done() before the test is finished, as the previous functions are asynchronous. You should probably move it to the last line of the last on-input function.
Thanks to both of you for pitching in. Truly believe this is something we should build more experience and share in the community.
Been trying lots of different angles on this. especially including having done() placed right:) Have been through lots of the core tests as well, and after tuning and learning, it seems my issue is that the config node. It doesnt seem to be configured right with credentials however I try it, and then my main node stops early due to lacking credentials. And for some reason I cannot seem to get spying on warn/debug/error to work like the examples, so bit hard to debug.
But I'm still getting undefined values. What does "nc" refer to in this example? I've been trawling through the node-red core source but it's like looking for a needle in a hasystack. Any suggestion how I can get this test working?
I ran my units tests in the Visual Studio javascript debugger and in a moment of inspiration I realised that the "nc" in the earlier example about was actually the name of the node in test flow. I changed the key in the javascript object to "n1" as per the names in my test flow and it now works perfectly.