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
This creates a symbolic link to your node module project directory in `~/.node-red/node_modules` so that Node-RED will discover the node when it starts. Any changes to the node's file can be picked up by simply restarting Node-RED. On Windows, again, using npm 5.x or greater:
177
+
This creates a symbolic link to your node module project directory in `~/.node-red/node_modules` so that Node-RED will discover the node when it starts. Any changes to the node's file can be picked up by simply restarting Node-RED. On Windows, again, using npm 5.x or greater:
175
178
176
179
<divclass="doc-callout">
177
180
<em>Note</em> : <code>npm</code> will automatically add an entry for your module in the
@@ -182,50 +185,67 @@ command.
182
185
183
186
### Unit Testing
184
187
185
-
To support unit testing, an npm module called [`node-red-node-test-helper`](https://www.npmjs.com/package/node-red-node-test-helper) can be used. The test-helper is a framework
188
+
To support unit testing, an npm module called [`node-red-node-test-helper`](https://www.npmjs.com/package/node-red-node-test-helper) can be used. The test-helper is a framework
186
189
built on the Node-RED runtime to make it easier to test nodes.
187
190
188
-
Using this framework, you can create test flows, and then assert that your node properties and output is working as expected. For example, to add a unit test to the lower-case node you can add a `test` folder to your node module package containing a file called `_spec.js`
191
+
To prepare the tests you need to add the test dependencies to your `package.json` file:
The test helper relies on NodeRED, so it needs to be added as development dependency.
198
+
199
+
Using this framework, you can create test flows, and then assert that your node properties and output is working as expected. For example, to add a unit test to the lower-case node you can add a `test` folder to your node module package containing a file called `_spec.js`
These tests check to see that the node is loaded into the runtime correctly, and that it correctly changes the payload to lower case as expected.
228
248
229
-
Both tests load the node into the runtime using `helper.load` supplying the node under test and a test flow The first checks that the node in the runtime has the correct name property. The second test uses a helper node to check that the output from the node is, in fact, lower case.
249
+
Both tests load the node into the runtime using `helper.load` supplying the node under test and a test flow The first checks that the node in the runtime has the correct name property. The second test uses a helper node to check that the output from the node is, in fact, lower case.
230
250
231
-
The helper module contains other examples of tests taken from the Node-RED core nodes. For more information on the helper module, see the associated README.
251
+
The helper module contains other examples of tests taken from the Node-RED core nodes. For more information on the helper module, see the associated README.
0 commit comments