-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Check data returned from setup() to ensure it contains only data, no functions. #558
Comments
Ah, good catch. Yes, we should definitely raise an exception if data returned by We need the data returned by |
I don't think to raise an exception would be the better approach, since the data in that object is still accessible. So, if you try the following you would get a response: export default function(globalData) {
console.log(globalData["db"].dbHost)
}; I guess a better way would document that functions won't be available as part of the data passed to the |
@robingustafsson and @na-- what do you think? |
It seems that currently the data returned by @luizbafilho, I agree that we should update the docs to mention this, but I think that it's also probably worth it to either emit a warning or exit with an error if users return non-data values from |
Apparently, if the object returned from setup() is an object that contains a function, or contains an object that contains a function (etc...) then that function is quietly stripped from the object, making it unavailable in the default() function call.
Instead, between the call to setup() and default(), the object returned from setup() should be examined and if it contains any non basic data type fields, an exception should be raised and the test aborted.
Alternatively, the data object could be provided to default() with its functions intact, but I imagine there may be other problems with that.
From eventdb.js
From test.js
The text was updated successfully, but these errors were encountered: