This is the example of Node-red unit and integration tests, based on the module node-red-node-test-helper.
This example was made based on the node-red-node-test-helper
module and there is a fork for the github module:jcbsfilho/node-red-node-test-helper
and made a change to expose httpin in routes.
Link to module node-red-node-test-helper.
Dependencies package.json
file:
...
"devDependencies": {
"node-red-node-test-helper": "github:jcbsfilho/node-red-node-test-helper",
"mocha": "^9.0.0",
"node-red": "^1.3.5"
}
...
npm run test-unit
npm run test-integration
npm run test
> mocha "./test/**/*.spec.js"
HTTP in Test Integration
POST /users
✓ missing payload in request expect 400 bad request (97ms)
✓ success creating the user 201 create
Function Unit Test
Function Name req entry
✓ required fields when invalid
✓ required fields when valid
Function Name check email
✓ check if the email is invalid
✓ check if the email is valid
6 passing (369ms)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.