How assert works in Node.js?
In Node.js, assert is used to write tests.
It only provides feedback only when any of the running test cases fails. This module gives you a set of assertion tests which are then used for testing invariants. It is basically used internally by Node.js but using require(‘assert’) code, it can be used in other applications as well.
1 2 3 4 5 6 | var assert = require( 'assert' ); function mul(a, b) { return a * b; } var result = mul( 1 , 2 ); assert ( result === 2 , 'one multiplied by two is two' ); |
Comments
Post a Comment