-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass settings as optional parameter to helper.load() #23
base: master
Are you sure you want to change the base?
Conversation
Hi - as per my comment on #21, I don't think this module should be reading files from disk. That doesn't really fit with the unit-testing role this module provides. The appropriate fix will be for the API this module exposes to allow you to pass in a settings object. You can then obtain that settings object in your own test code however you want. |
Hi Nick, Updated the PR. The Casper |
Hi Nick, The release of node-red v0.19.4 seems to have broken my feature.
Any idea why? |
In 0.19.4 we made the context.get/set functions non-enumerable properties so they can't be accidentally deleted - a user had a flow that was doing so and breaking the internals of Node-RED. What is the Function node you are testing doing? |
The function node has a dependency on moment.js, which is passed in through I noticed today that with the 0.19.4 version, my first test still passes, but the following tests fail. My suspicion is that somehow the settings are not cleared in between tests, and that the second test tries to overwrite the settings, leading to the error above. Haven't had much time to look into it today, but was just wondering: Why is |
The However - global context is a special case - it never gets cleaned. So I suspect you are right that your changes are causing to reinitialise the existing global context object which it doesn't like. I'll try to recreate based on that theory - although it won't be for a day or two. |
I have recreated the issue. The first test passes, the next 4 fail. If the node-red dependency is downgraded to 0.19.3, all tests pass. Thanks for taking the time to look into this. I really appreciate it. |
By the way, why is the global context never cleaned? What would be the solution to my problem? Should I somehow change the helper to accept the |
At the moment it is impossible to test a flow which has a function node, which loads a module with a call to
global.get()
. (See the documentation on loading modules in function nodes.)This PR adds the functionality, such that the test-helper loads a
settings.js
file from the current working directory (if present). Thus it will be possible to specify modules withsettings.functionGlobalContext
.