-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
feature request for assert core module #5312
Comments
Offhand, I'm unaware of any userland assertion testing library that has this feature, but it might be worth looking. I suspect you already are doing something like this, but just in case, a simple workaround for your issue might look something like this:
Or:
|
Yeah that will, I was kind of curious to see how useful this callback feature might be, probably not that useful and your suggestion should work, thanks |
Node.js assertion module is not meant for general purpose use. Unless Node.js requires this feature, it wouldn't be implemented and as of now we don't have a pressing usecase. |
@ORESoftware Since 81f2c9317aa9f9b4e69ed7a60dbecd8affd462a8 landed, you don't have to do Do note that the commit hasn't landed in node 5.x and will not land until node 6.x. |
Closing as the assert module is locked. Thanks! |
@thefourtheye why is the assert module not meant for general purpose use? I've tried using it on small projects instead of things Shouldjs and have found it meets my needs well. Basically the same question as this one on Stack Overflow |
@mheiber #4532 and other issues allude to the reason the documentation recommends against using A little more context: Knowing what we now know, if we were designing/building Node.js core all over again, the The reasons for this, at least from my perspective are:
There's additional context that others may choose to add here or not (such as why, all things being equal, we would favor keeping core small and doing things in userland). But that's the so-called 30,000 foot view. Since True, if you're doing straightforward assertions with simple cases, I hope this is helpful and answers your question. |
@Trott this answer rules, thank you |
@mheiber Heh, thanks. If you wish, consider upvoting the answer's twin at http://stackoverflow.com/a/39284536/436641 to increase its visibility there. |
"Knowing what we now know, if we were designing/building Node.js core all over again, the assert module would either not exist in Node.js or else consist of far fewer functions--quite possibly just assert() (which is currently an alias for assert.ok())." see nodejs/node#5312 (comment)
I have a simple case
the problem is of course, if err is null, the assert message will still get evaluated, so it will throw a new/preemptive error saying
I know assert is stable and not likely to change, but the feature I am looking for is somthing like this
this of course means, that the callback will only be evaluated if the assertion fails
hope that makes sense, thanks!
The text was updated successfully, but these errors were encountered: