Reputation: 3265
I was nearly through porting YUI assertion modules to standalone libraries when the thought popped into mind that I should have perhaps asked on StackOverflow if this was necessary first. However I finished the libs:
YUIPort: https://github.com/gso/YUIPort
But thought I would duly ask as well. Are there any good quality standalone libraries of assert functions - these can be very useful, e.g., checking the validity of arguments passed to functions (can save a lot of time invoking the debugger).
Upvotes: 27
Views: 12903
Reputation: 3265
As of May 7, 2012
After some brief research, starting with the most minimalistic:
I have to admit that I do tend to agree with a commenter on DailyJS:
I don't understand why everyone likes these wordy assertion libraries.
Although I'm not a CoffeeScript user, I do tend to gravitate towards the plain assert.js style syntax rather than all this chaining.
Features that these libraries are developing include:
Some of the major test suites include:
The major web frameworks often include their own test suites.
Logging wise, there is a discussion on libraries available. They don't, at a glance, seem to have caught up with server-side JS as of yet.
Upvotes: 28
Reputation: 169401
function assert(condition, message) {
if (!condition) throw new Error(message)
}
Upvotes: 25