node-red / node-red-node-test-helper

A test framework for Node-RED nodes
Apache License 2.0
57 stars 40 forks source link

Testing failed by timeout #58

Closed naoyaikeda closed 1 year ago

naoyaikeda commented 1 year ago

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/gorn/Projects/NESIC/NESIC-PowerIoT_Docker/nodes/NESIC-PowerIoT_Nodes-DateOperation/test/GetDuration_spec.js)

Test was failed by Timeout

naoyaikeda commented 1 year ago

I confirmed okay

const should = require("should"); const helper = require('node-red-node-test-helper'); const getDuration = require("../GetDuration.js");

helper.init(require.resolve('node-red'));

describe('GetDuration Node', function () {

afterEach(function () { helper.unload(); });

it('should be loaded', function (done) { var flow = [{ id: "n1", type: "getDuration", name: "test name" }]; helper.load(getDuration, flow, function () { var n1 = helper.getNode("n1"); n1.should.have.property('name', 'test name'); done(); }); });

it('should make right duration', function (done) { var flow = [{ id: "n1", type: "getDuration", name: "test name",wires:[["n2"]] }, { id: "n2", type: "helper" }]; helper.load(getDuration, flow, function () { var n2 = helper.getNode("n2"); var n1 = helper.getNode("n1"); n2.on("input", function (msg) { try { msg.should.have.property('payload', {'start': '1999/01/01 01:00:00', 'end': '1999/01/01 01:01:00', 'duration': '0:01:00'}); done(); } catch(err) { done(err); } }); n1.receive({ payload: {'start': '1999/01/01 01:00:00', 'end': '1999/01/01 01:01:00', 'duration': '0:05:00'} }); }); }); });