Asserts are not just for testing
· ☕ 2 min read
Assert is a general-purpose validator and should not be used in the context of testing alone.
An assert in Javascript simply checks for truthy values and produces an error otherwise. We use it quite a bit in automated testing when checking for correctness of output for pre-defined inputs.
We use asserts like so -