How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import assert from 'assert/strict';
    
    // This fails because 1 !== '1'.
    assert.deepStrictEqual({ a: 1 }, { a: '1' });
    // AssertionError: Expected inputs to be strictly deep-equal:
    // + actual - expected
    //
    //   {
    // +   a: 1
    // -   a: '1'
    //   }
    
    // The following objects don't have own properties
    const date = new Date();
    const object = {};
    const fakeDate = {};
    Object.setPrototypeOf(fakeDate, Date.prototype);
    
    // Different [[Prototype]]:
    assert.deepStrictEqual(object, fakeDate);
    // AssertionError: Expected inputs to be strictly deep-equal:
    // + actual - expected
    //
    // + {}
    // - Date {}
    
    // Different type tags:
    assert.deepStrictEqual(date, fakeDate);
    // AssertionError: Expected inputs to be strictly deep-equal:
    // + actual - expected
    //
    // + 2018-04-26T00:49:08.604Z
    // - Date {}
    
    assert.deepStrictEqual(NaN, NaN);
    // OK because Object.is(NaN, NaN) is true.
    
    // Different unwrapped numbers:
    assert.deepStrictEqual(new Number(1), new Number(2));
    // AssertionError: Expected inputs to be strictly deep-equal:
    // + actual - expected
    //
    // + [Number: 1]
    // - [Number: 2]
    
    assert.deepStrictEqual(new String('foo'), Object('foo'));
    // OK because the object and the string are identical when unwrapped.
    
    assert.deepStrictEqual(-0, -0);
    // OK
    
    // Different zeros:
    assert.deepStrictEqual(0, -0);
    // AssertionError: Expected inputs to be strictly deep-equal:
    // + actual - expected
    //
    // + 0
    // - -0
    
    const symbol1 = Symbol();
    const symbol2 = Symbol();
    assert.deepStrictEqual({ [symbol1]: 1 }, { [symbol1]: 1 });
    // OK, because it is the same symbol on both objects.
    
    assert.deepStrictEqual({ [symbol1]: 1 }, { [symbol2]: 1 });
    // AssertionError [ERR_ASSERTION]: Inputs identical but not reference equal:
    //
    // {
    //   [Symbol()]: 1
    // }
    
    const weakMap1 = new WeakMap();
    const weakMap2 = new WeakMap([[{}, {}]]);
    const weakMap3 = new WeakMap();
    weakMap3.unequal = true;
    
    assert.deepStrictEqual(weakMap1, weakMap2);
    // OK, because it is impossible to compare the entries
    
    // Fails because weakMap3 has a property that weakMap1 does not contain:
    assert.deepStrictEqual(weakMap1, weakMap3);
    // AssertionError: Expected inputs to be strictly deep-equal:
    // + actual - expected
    //
    //   WeakMap {
    // +   [items unknown]
    // -   [items unknown],
    // -   unequal: true
    //   }
    Docs
  • const assert = require('assert/strict');
    
    assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
    // OK
    Docs
  • import assert from 'assert/strict';
    
    assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
    // OK
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples