Search code examples
javascriptassertassertions

Assertions in JavaScript


Extensively reading about various assertion frameworks in JavaScript. Is there any kind of de-facto/most common "standard" library/framework? When selecting one - which points are most worth noticing?

The (only) requirement I can think about is close-to-zero performance overhead when in production mode.


Solution

  • Two possible solutions:

    Have your build release script remove the Assert lines.

    or

    Have your build script override the Assert function so it is just an empty function. Downside to this is if you assert call has logic in it [aka assert( x > 100 , "foo" )] than that logic [x > 100] is still going to be run.