Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In node-red-node-test-helper input handler not called on errors and warnings #83

Closed
ttoktassynov opened this issue Aug 17, 2021 · 0 comments · Fixed by #91
Closed

In node-red-node-test-helper input handler not called on errors and warnings #83

ttoktassynov opened this issue Aug 17, 2021 · 0 comments · Fixed by #91
Assignees
Labels
bug Something isn't working

Comments

@ttoktassynov
Copy link
Member

Beware that if you are testing an error or warning condition of your node behavior then currently input handler doesn't get called while unit testing.

So assuming this code:

// somewhere in FooNode constructor
this.on('input', msg => {
  if (msg.omg) {
    this.error('lolwtf');
  }
  // ..etc..
});

This wouldn't work:

describe('if `omg` in input message', function () {
  it('should call `error` with "lolwtf" ', function (done) {
    const flow = {
      name: 'n1',
      /* ..etc.. */
    };
    helper.load(FooNode, flow, function () {
      const n1 = helper.getNode('n1')
      n1.receive({omg: true});
      n1.on('input', () => {
        n1.warn.should.be.calledWithExactly('lolwtf');
        done();
      });
    });
  });
});

It would just result in timeout.
Here is reported issue

@ttoktassynov ttoktassynov added the other Miscellaneous topic not covered by other labels label Aug 17, 2021
@ttoktassynov ttoktassynov linked a pull request Aug 20, 2021 that will close this issue
@louislefevre louislefevre added bug Something isn't working and removed other Miscellaneous topic not covered by other labels labels Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants