node-red-node-test-helper
node-red-node-test-helper copied to clipboard
Added support to paste flows exported from editor
- Allows flows to be create in editor and pasted into test scripts as JSON string. Backwards compatible with existing test flow definitions.
- Automatically creates a flow to hold the test nodes so that Catch and Status nodes work.
- Automatically converts Debug nodes into Helper nodes so that links can be set up between nodes using the editor.
- Adds error handler to override node error handler so that test failures are passed back to mocha and not swallowed by Node Red
- Fixes some existing tests that fail the stop the help server after tests are completed.
- Documentation added for linking dependencies instead of installing them.
Currently the test helper doesn't use the Node Red registry to load the core nodes or other installed nodes. As a result it uses a deprecated interface to initialise nodes and requires the nodes in the test flow to be explicitly requireed in the test script.
I'm not sure how far to go with this. The original test harness started the bare minimum of Node Red to be able to run a node. This PR starts a bit more of Node Red to support a flow to contain the nodes being tested. Starting the registry effectively starts 90% of Node Red, at which point we might as well start the whole thing and embed it in the test module. The overhead of this isn't as bad as it sounds - you can start Node Red at the start of the test script and then add/remove flows for each test.
Thanks Dean. Ok. I'll have a look. Busy this week so might be slower to respond.
On Mon, Feb 26, 2018, 7:50 AM Dean Cording [email protected] wrote:
Currently the test helper doesn't use the Node Red registry to load the core nodes or other installed nodes. As a result it uses a deprecated interface to initialise nodes and requires the nodes in the test flow to be explicitly requireed in the test script.
I'm not sure how far to go with this. The original test harness started the bare minimum of Node Red to be able to run a node. This PR starts a bit more of Node Red to support a flow to contain the nodes being tested. Starting the registry effectively starts 90% of Node Red, at which point we might as well start the whole thing and embed it in the test module. The overhead of this isn't as bad as it sounds - you can start Node Red at the start of the test script and then add/remove flows for each test.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/node-red/node-red-node-test-helper/pull/2#issuecomment-368547716, or mute the thread https://github.com/notifications/unsubscribe-auth/AArMeBusWT-1ChTaaY98qlcgRRhc_6WJks5tYtLTgaJpZM4STZmM .
My 2c - my preference would be to prioritise getting this to the point where we can run the tests we already have in core using this module rather than the helper bundled over there. Only then should we look at what other apis/features are potentially missing.
This test helper is demonstrably useful as-is - so lets stabilise that and get it documented and publicised.
OK - agreed
The best way to test that the helper will serve both core and contrib nodes will be to add the test helper module to the core as a dependency and use that code to run the core tests. I will work on that to ensure it works, and do a PR on the core. I suggest we set this PR aside for now and continue this conversation on slack? How about a new #testing channel?
Curious to see if there are plans ton include this ? I'm looking for an easier way to test longer flows and it seems this PR could help.