Basically pulled out the helper.js code from the tests and modified it slightly so it can be used in your own nodes. I started to document the helper API in the readme, and provided a short example unit test for the 'lower-case' node. Hopefully you find it useful.
Mike
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/zyWkVvwoA44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/2210c278-d607-4c6d-903e-e57d574662fd%40googlegroups.com.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/zyWkVvwoA44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/dd6dfcd9-5240-49f1-ba70-7efd160fcc32%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/CABD_Zox9MattOjvpSJpLduv_yNbrX8LTDtpvhkN3hxPoeHf-sw%40mail.gmail.com.
npm install -g mocha should node-red-node-test-helper
npm link should
npm link node-red-test-helper
If you use npm >=3 then you won't get multiple copies of everything. NPM works hard to install modules as high as possible in the tree where it can - rather than a huge tree of node_modules as you used to get in npm 2 and earlier. This was one of the reasons we hadn't pulled out the test helper earlier on in the projects life - but big thanks to Mike for getting this done now.I would suggest relaxing the node-red module dependency to 0.18.x at least - otherwise that will definitely cause multiple installs each time we release a new version.Nick
On 22 February 2018 at 17:17, Mike Blackstock <mikebla...@gmail.com> wrote:
Thanks for trying it out Dean. Yeah, there is a lot of stuff pulled in... Let me know if you manage to get a global install working or you have any other suggestions.
Mike
On Feb 22, 2018 5:03 PM, "Dean Cording" <dean+...@cording.id.au> wrote:
Thanks Mike,One thing you should consider is that doing a local install of the node-red-node-test-helper also drags in over 400 other packages (totalling 63Mb) including a full node-red package and all of the core nodes. With my twenty odd nodes, it soon adds up.Doing a global install would be a better option, however I'm having trouble getting it to work for some reason.Dean
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/zyWkVvwoA44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/dd6dfcd9-5240-49f1-ba70-7efd160fcc32%40googlegroups.com.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/2552e4a1-859a-4f10-9274-a1f4d8c28acc%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/CAF%3DvhqfRrCcNJyZ3MqhYpV5BLhG1tg_ycf-1qM71FO3kqRXMGA%40mail.gmail.com.
var flow1 = [
{
id: "c1",
type: "catch",
name: "",
scope: [
"n1"
],
wires: [
["h1"]
]
},
{
id: "n1",
type: "state-machine",
name: "Test",
triggerProperty: "topic",
triggerPropertyType: "msg",
stateProperty: "state",
statePropertyType: "msg",
outputStateChangeOnly: false,
throwException: false,
states: [
"start",
"state1",
"state2",
"state3"
],
transitions: [
{
name: "t1",
from: "start",
to: "state1"
},
{
name: "t2",
from: "state1",
to: "state2"
},
{
name: "t3",
from: "state2",
to: "state3"
},
{
name: "t4",
from: "state3",
to: "state1"
},
{
name: "r",
from: "*",
to: "start"
}
],
wires: [
[
"h1"
]
]
},
{
id: "h1",
type: "helper"
}
];
npm link node-red
var stateMachineNode = require('./state-machine.js');
var catchNode = require('node-red/nodes/core/core/25-catch.js');
helper.load([stateMachineNode, catchNode], flow1, function () {
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/zyWkVvwoA44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/f4a74438-e475-4547-bb9c-546b76e22a76%40googlegroups.com.
Install it locally if you're going to require() it.
Install it globally if you're going to run it on the command line.
If you need both, then install it in both places, or use npm link.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/zyWkVvwoA44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/62c42388-8f8e-405d-b26f-53854e9c823d%40googlegroups.com.
var flow = [
{ id: "f1", type: "tab", label: "Test Flow"},
{ id: "n1", z: "f1", type: "lower-case", name: "lower-case",wires:[["n2"]] },
{ id: "n2", z: "f1", type: "helper" }
];
log.init({});
logSpy = sinon.spy(log,"log");
function helperNode(n) {
RED.nodes.createNode(this, n);
this.error = function(logMessage,msg) {
console.log(logMessage);
}
}