assert.strictEqual()

assert.strictEqual(actual, expected[, message]) Tests strict equality as determined by the strict equality operator ( === ). const assert = require('assert'); assert.strictEqual(1, 2); // AssertionError: 1 === 2 assert.strictEqual(1, 1); // OK assert.strictEqual(1, '1'); // AssertionError: 1 === '1' If the values are not strictly equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default

assert.throws()

assert.throws(block[, error][, message]) Expects the function block to throw an error. If specified, error can be a constructor, RegExp, or validation function. If specified, message will be the message provided by the AssertionError if the block fails to throw. Validate instanceof using constructor: assert.throws( () => { throw new Error('Wrong value'); }, Error ); Validate error message using RegExp: assert.throws( () => { throw new Error('Wrong value'); }, /val

assert.notStrictEqual()

assert.notStrictEqual(actual, expected[, message]) Tests strict inequality as determined by the strict not equal operator ( !== ). const assert = require('assert'); assert.notStrictEqual(1, 2); // OK assert.notStrictEqual(1, 1); // AssertionError: 1 != 1 assert.notStrictEqual(1, '1'); // OK If the values are strictly equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message

assert.ok()

assert.ok(value[, message]) Tests if value is truthy. It is equivalent to assert.equal(!!value, true, message). If value is not truthy, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned. const assert = require('assert'); assert.ok(true); // OK assert.ok(1); // OK assert.ok(false); // throws "AssertionError: false == true" assert.ok(0); // throws "AssertionErr

assert.notEqual()

assert.notEqual(actual, expected[, message]) Tests shallow, coercive inequality with the not equal comparison operator ( != ). const assert = require('assert'); assert.notEqual(1, 2); // OK assert.notEqual(1, 1); // AssertionError: 1 != 1 assert.notEqual(1, '1'); // AssertionError: 1 != '1' If the values are equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assig

assert.notDeepStrictEqual()

assert.notDeepStrictEqual(actual, expected[, message]) Tests for deep strict inequality. Opposite of assert.deepStrictEqual(). const assert = require('assert'); assert.notDeepEqual({a:1}, {a:'1'}); // AssertionError: { a: 1 } notDeepEqual { a: '1' } assert.notDeepStrictEqual({a:1}, {a:'1'}); // OK If the values are deeply and strictly equal, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a defaul

assert.notDeepEqual()

assert.notDeepEqual(actual, expected[, message]) Tests for any deep inequality. Opposite of assert.deepEqual(). const assert = require('assert'); const obj1 = { a : { b : 1 } }; const obj2 = { a : { b : 2 } }; const obj3 = { a : { b : 1 } } const obj4 = Object.create(obj1); assert.notDeepEqual(obj1, obj1); // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } assert.notDeepEqual(obj1, obj2); // OK, obj1 and obj2 are not deeply equal assert.notDeepEqual

assert.ifError()

assert.ifError(value) Throws value if value is truthy. This is useful when testing the error argument in callbacks. const assert = require('assert'); assert.ifError(0); // OK assert.ifError(1); // Throws 1 assert.ifError('error') // Throws 'error' assert.ifError(new Error()); // Throws Error

assert.equal()

assert.equal(actual, expected[, message]) Tests shallow, coercive equality between the actual and expected parameters using the equal comparison operator ( == ). const assert = require('assert'); assert.equal(1, 1); // OK, 1 == 1 assert.equal(1, '1'); // OK, 1 == '1' assert.equal(1, 2); // AssertionError: 1 == 2 assert.equal({a: {b: 1}}, {a: {b: 1}}); //AssertionError: { a: { b: 1 } } == { a: { b: 1 } } If the values are not equal, an AssertionError is thrown with a message property

assert.fail()

assert.fail(actual, expected, message, operator) Throws an AssertionError. If message is falsy, the error message is set as the values of actual and expected separated by the provided operator. Otherwise, the error message is the value of message. const assert = require('assert'); assert.fail(1, 2, undefined, '>'); // AssertionError: 1 > 2 assert.fail(1, 2, 'whoops', '>'); // AssertionError: whoops