| Node.js Assertion
Node.js Assertion Testing
When we say about the Node.js Assert it is one of the most elementary way to write tests. This will not provides feedback when running your test unless one fails. And assert modules will provides a simple set of assertion tests which can be used to test invariants. And this module is intended for internal use by Node.js, but ir can be used in application code by require('assert').
However assert is not a testing framework and cannot be used as general purpose assertion library.
Node.js Assertion Example
To understand Node.js assertion below is the simple example of Node.js Assert:-
File: assert_example1.js
And this above code will not provide any output because the case is true. And if you want to check the output then you need to make a test fail case.
File: assert_example2.js
Now once you run above code you will get the below AssertionError.
| | |