Node-red-node-test-helper

#1

I’m working on the ‘mytimeout’ node (a countdown node) and I’m trying to add testing. I have three things to bring up

1) I want to add testing to my node. So I went to the node-red create your first Node (unit testing). I think the unit testing section needs to be updated as the package name has changed and the node-red-node-test-helper github page is quite different.

2) Now following the instructions on the github page I’ve run into a problem. I need to start the new node-red server on a different port as I already have a node-red server running on the default port. So how do I run the test on a different port number?

3) I have a node with 2 outputs. I’m not quite sure how to add the second output for testing. Since I can’t get the previous item resolved I’m not in a rush to get to thing but eventually I’ll need to figure this part out also.

I’ll have further questions later. Right now getting something working is the first step, then pass a few simple tests then I’ll get to the complex tests.

Thanks

0 Likes

#2

If you mean the “standard” port 1880
See uiPort in settings.js https://nodered.org/docs/configuration

0 Likes

#3

I’m not sure how to apply that. The test is called via the package.json

{
  {
    "scripts": {
      "test": "mocha \"test/**/*_spec,js\""
    }
  }
}

Since the node-red-node-test-helper appears to be what calls node-red, I’m not sure what to set to make it run on a different port while the default node-red uses the 1880 port. Changing the default settings file will break the default node-red.

0 Likes

#4

Found a solution:

PORT=4880 npm test

This will cause the node-re to run on port 4880. Change the port as needed.

Unfortunately it also ran the default config (all my real flows). Hmm, need to figure this out. :frowning:

0 Likes