const assert = require('assert'); let result = 5; assert.equal(result, 5); // passes assert.equal(result, 3); // throws an error
const assert = require('assert'); function addNumbers(a, b) { return a + b; } assert.strictEqual(addNumbers(2, 3), 5); // passes assert.strictEqual(addNumbers(4, 2), 8); // throws an errorThe assert library is included in Node.js by default, but can also be used in browser-based JavaScript applications by importing the Chai Assertion Library.