Closed louislefevre closed 3 years ago
Nice work, Louis! Just one thing, instead of using .test.js for the file names, I think Node-RED convention is to use _spec.js for the tests so that it works with the node-red-test-helper framework. This is my understanding based on the unit testing guidance here: https://nodered.org/docs/creating-nodes/first-node#testing-your-node-in-node-red
There are two standard conventions for naming test files in JS: *.test.js
and *.spec.js
. The one used by the node-red-test-helper is just the convention they went with, though using a different one shouldn't stop it from working. The only purpose of the name is so that you can specify a glob for Mocha to look for when searching for test files, other than clarification on the purpose of the file. Personally, I find using the word "test" to be clearer than "spec", as it's more immediately clear what the purpose of the file is. What do you think?
Nice work, Louis! Just one thing, instead of using .test.js for the file names, I think Node-RED convention is to use _spec.js for the tests so that it works with the node-red-test-helper framework. This is my understanding based on the unit testing guidance here: https://nodered.org/docs/creating-nodes/first-node#testing-your-node-in-node-red
There are two standard conventions for naming test files in JS:
*.test.js
and*.spec.js
. The one used by the node-red-test-helper is just the convention they went with, though using a different one shouldn't stop it from working. The only purpose of the name is so that you can specify a glob for Mocha to look for when searching for test files, other than clarification on the purpose of the file. Personally, I find using the word "test" to be clearer than "spec", as it's more immediately clear what the purpose of the file is. What do you think?
Ah ok. While I do agree with you that "test" would be the clearer terminology to use, I'm not sure that we should diverge from the way chosen for Node-RED, since we're making a Node-RED palette. @Theo-Reignier what do you think about the naming of the test files?
Nice work, Louis! Just one thing, instead of using .test.js for the file names, I think Node-RED convention is to use _spec.js for the tests so that it works with the node-red-test-helper framework. This is my understanding based on the unit testing guidance here: https://nodered.org/docs/creating-nodes/first-node#testing-your-node-in-node-red
There are two standard conventions for naming test files in JS:
*.test.js
and*.spec.js
. The one used by the node-red-test-helper is just the convention they went with, though using a different one shouldn't stop it from working. The only purpose of the name is so that you can specify a glob for Mocha to look for when searching for test files, other than clarification on the purpose of the file. Personally, I find using the word "test" to be clearer than "spec", as it's more immediately clear what the purpose of the file is. What do you think?Ah ok. While I do agree with you that "test" would be the clearer terminology to use, I'm not sure that we should diverge from the way chosen for Node-RED, since we're making a Node-RED palette. @Theo-Reignier what do you think about the naming of the test files?
I do not know how much the testing file naming conventions are important. However, since there is no need to make the file names user-friendly, I would stick with the Node-RED conventions.
@KhesimReid I've pushed a commit to update the names 👍
@KhesimReid I've pushed a commit to update the names 👍
Thanks Louis!
Purpose
Added unit test templates for every node to get things started. Each node only contains a loading test right now, but figured it would be a good idea to merge these templates now for consistency in case others start adding unit tests.
Added a helper class for providing common unit test functionality. Given that many of the nodes will probably be tested in similar ways, figured it would be a good idea to create a single file where that common functionality can be called from.
Also updated the projects dependencies.
Changes
node-red-test-helper
dev dependency (0fbb8e1bcf5be8a7dfaff5d815b0213bf3609151).New Requirements
node-red-test-helper
has been added. Ensure you runnpm install
.