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

  • const assert = require('assert/strict');
    assert.match('I will fail', /pass/);
    // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
    assert.match(123, /pass/);
    // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
    assert.match('I will pass', /pass/);
    // OK
  • assert.notStrictEqual(3, '3', 'no coercion for strict equality');
  • import assert from 'assert/strict';
    assert.doesNotMatch('I will fail', /fail/);
    // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
    assert.doesNotMatch(123, /pass/);
    // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
    assert.doesNotMatch('I will pass', /different/);
    // OK
  • import assert from 'assert/strict';
    function throwingFirst() {
      throw new Error('First');
    function throwingSecond() {
      throw new Error('Second');
    function notThrowing() {}
    // The second argument is a string and the input function threw an Error.
    // The first case will not throw as it does not match for the error message
    // thrown by the input function!
    assert.throws(throwingFirst, 'Second');
    // In the next example the message has no benefit over the message from the
    // error and since it is not clear if the user intended to actually match
    // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
    assert.throws(throwingSecond, 'Second');
    // The string is only used (as message) in case the function does not throw:
    assert.throws(notThrowing, 'Second');
    // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
    // If it was intended to match for the error message do this instead:
    // It does not throw because the error messages match.
    assert.throws(throwingSecond, /Second$/);
    // If the error message does not match, an AssertionError is thrown.
    assert.throws(throwingFirst, /Second$/);
    // AssertionError [ERR_ASSERTION]
  • assert.notMatch('foobar', /^foo/, 'regexp does not match');
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples