I'm coming to grips with npm test (mocha) with my node: node-red-contrib-mytimeout (github dev-test branch). Since I'm just starting I'm learning about mocha and building tests. There's a lot that I don't understand. For instance
I have a test case that sends an "on" ( '{ "payload": "on" }' ) but I keep getting.
1) mytimeout Node 2
Should turn on:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/njc/dev/git/node-red-contrib-mytimeout/t/dev-test/test/basic2_spec.js)
The node mytimeout has gotten a bit complex but basically in it's default state if I send an "on" payload, it starts the time and it will send an "on" to the first output, 25 seconds later it send "warning" and 5 seconds "off".
https://github.com/linuxha/node-red-contrib-mytimeout/blob/feature/dev-test/test/basic2_spec.js.
/*
** Main output
** n2: {"_msgid":"65d8f152.8e917","payload":"on","topic":"","timeout":30}
** Ticks output
** n3: {"payload":30,"state":1,"flag":"ticks > 0","_msgid":"5e5dd4bf.1be32c"}
*/
it('Should turn on', function (done) {
var flow = [
{ id: "n1", type: "mytimeout", name: nom, wires:[["n2"]] },
{ id: "n2", type: "helper" }
];
helper.load(myNode, flow, function () {
var n2 = helper.getNode("n2");
var n1 = helper.getNode("n1");
n2.on("input", function (msg) {
console.log("NJC: msg.payload = " + msg.payload);
console.log("NJC: msg = " + JSON.stringify(msg));
msg.should.have.property('payload', 'on');
done();
});
n1.receive({ payload: 'on' });
});
});