You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+15-5
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,12 @@ describe('lower-case Node', function () {
73
73
var flow = [{ id:"n1", type:"lower-case", name:"lower-case" }];
74
74
helper.load(lowerNode, flow, function () {
75
75
var n1 =helper.getNode("n1");
76
-
n1.should.have.property('name', 'lower-case');
77
-
done();
76
+
try {
77
+
n1.should.have.property('name', 'lower-case');
78
+
done();
79
+
} catch(err) {
80
+
done(err);
81
+
}
78
82
});
79
83
});
80
84
@@ -87,8 +91,12 @@ describe('lower-case Node', function () {
87
91
var n2 =helper.getNode("n2");
88
92
var n1 =helper.getNode("n1");
89
93
n2.on("input", function (msg) {
90
-
msg.should.have.property('payload', 'uppercase');
91
-
done();
94
+
try {
95
+
msg.should.have.property('payload', 'uppercase');
96
+
done();
97
+
} catch(err) {
98
+
done(err);
99
+
}
92
100
});
93
101
n1.receive({ payload:"UpperCase" });
94
102
});
@@ -100,9 +108,11 @@ In this example, we require `should` for assertions, this helper module, as well
100
108
101
109
We then have a set of mocha unit tests. These tests check that the node loads correctly, and ensures it makes the payload string lower case as expected.
102
110
111
+
Note how the assertion failures are caught explicitly and passed to the `done()` call. Node-RED swallows exceptions that are raised in the flow, so we make sure the test framework is aware of them. Not doing so would simply lead to a test timeout because `done()` is never called in case of an assertion failure.
112
+
103
113
## Initializing Helper
104
114
105
-
To get started, we need to tell the helper where to find the node-red runtime. this is done by calling `helper.init(require.resolve('node-red'))` as shown.
115
+
To get started, we need to tell the helper where to find the node-red runtime. This is done by calling `helper.init(require.resolve('node-red'))` as shown.
106
116
107
117
The helper takes an optional `userSettings` parameter which is merged with the runtime defaults.
0 commit comments