assert in node js code example
Example 1: how to assert in javascript
const hello = require('../hello.js');
const assert = require('assert');
describe("hello", function(){
it("should return custom message when name is specified", function(){
assert.strictEqual(hello("Jasmine"), "Hello, Jasmine!");
});
});
assert.strictEqual(hello("Jasmine"), "Hello, Jasmine!");
Example 2: const { message } = new assert.AssertionError({ actual: 1, expected: 2, operator: 'strictEqual' });
const { bar } = foo;
const { message } = new assert.AssertionError({
actual: 1,
expected: 2,
operator: 'strictEqual'
});