Capturing input messages with node-red-node-test-helper not working


recently I started writing unit tests for my Node-RED nodes. I'm using node-red-node-test-helper and already implemented a couple of tests which work just fine.

But now I got stuck implementing a test which involves sending a message from my node to the helper node. I just cannot get it working, the callback function for the "input" event is never called. But I'm sure that my node sends a message during the test. I verified this by instrumenting the code and saw that the send function is called. Additionally I faked the test to pass and measured the coverage and also here I saw that the send function was called.

The code of the node under test is available on GitHub:

This is my test code:

const sinon = require("sinon");

const helper = require("node-red-node-test-helper");
const configNode = require("../nodes/config.js");
const schedulerNode = require("../nodes/scheduler.js");
const chronos = require("../nodes/common/chronos.js");
const moment = require("moment");

describe("scheduler node", function()
    context("node timers", function()
        let clock = null;



            clock = sinon.useFakeTimers();
            sinon.stub(chronos, "getCurrentTime").returns(moment().utc());


        it("should trigger at specified time", async function(done)
            const flow = [{id: "sn1", type: "chronos-scheduler", name: "scheduler", config: "cn1", wires: [["hn1"]], schedule: [{trigger: {type: "time", value: "00:01", offset: 0, random: false}, output: {type: "msg", property: {name: "payload", type: "string", value: "test"}}}], outputs: 1},
                          {id: "hn1", type: "helper"},
                          {id: "cn1", type: "chronos-config", name: "config"}];
            const credentials = {"cn1": {latitude: "50", longitude: "10"}};

            await helper.load([schedulerNode, configNode], flow, credentials);
            const hn1 = helper.getNode("hn1");

            hn1.on("input", function(msg)
          "payload", "test");


I always get this error from mocha as the done function is never called:

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

Any idea what I'm doing wrong and how I can get this working?

Best regards,

Any help? I know that node-red-node-test-helper is not used so widely outside of the Node-RED core development, but maybe someone from the Node-RED development team has an idea? Could it be related to the usage of sinonjs fake timers? Or maybe because of using a configuration node and credentials? There do not seem to exist comparable examples from the node-red-node-test-helper repository or the Node-RED unit tests.

I'll try to take a look tonight. I can't see anything obvious from the code you've shared. As you note, there aren't comparable examples in the core tests - in particular, we`ve never used the fake timers provided by Sinon (although perhaps we should...).