Node-red-node-test issues, getting output from node


#1

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...

it('should fetch status', function (done) {
    // setup intercepts
    nock(netScope)
      .get('/xbn/2/installation/search?email=' + verEmail)
      .replyWithFile(200, `${__dirname}/sites_reply.json`);
    nock(netScope)
      .get('/xbn/2/cookie')
      .replyWithFile(200, `${__dirname}/token_reply.xml`);
    nock(netScope)
      .get('/xbn/2/installation/123456789/overview')
      .replyWithFile(200, `${__dirname}/test_site.json`);
    // define flow to test
    var flow = [{ 'id': 'n1', 'type': 'VerisureAlarmNode', 'z': 'f1', 'name': 'Verisure Alarm', 'user': 'nc', 'x': 240, 'y': 240, 'wires': [ ['nh'] ] },
      { 'id': 'nc', 'type': 'VerisureConfig', 'z': 'f1', 'displayName': 'Verisure Site', 'siteName': 'Home', 'username': verEmail, 'password': verPassword },
      { id: 'nh', type: 'helper', 'z': 'f1' },
      { id: 'f1', type: 'tab', label: 'Test flow' }
    ];
    // console.log(helper.log());
    helper.load([sureNode, confNode], flow, function () {
      var n1 = helper.getNode('n1');
      var nc = helper.getNode('nc');
      var nh = helper.getNode('nh');
      nc.should.have.property('username', verEmail);
      n1.on('call:warn', function (msg) {
        console.log('warning N1: ' + msg);
      });
      nh.on('input', function (msg) {
        msg.payload.should.be('{"currentStatus":"DISARMED","changed":"false","date":"2018-11-08T06:54:28.000Z","name":"Kristian"}');
        console.log('Test message received NH: ' + msg);
        done();
      });
      n1.on('input', function (msg) {
        console.log('Test message received N1: ' + msg.payload);
      });
      n1.receive({ payload: 'test' });
      done();
    }); // should fetch status