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.throws(
      () => {
        throw new Error('Wrong value');
      },
      Error
    );
    Docs
  • assert.throws(fn, 'Error thrown must have this msg');
    assert.throws(fn, /Error thrown must have a msg that matches this/);
    assert.throws(fn, ReferenceError);
    assert.throws(fn, errorInstance);
    assert.throws(fn, ReferenceError, 'Error thrown must be a ReferenceError and have this msg');
    assert.throws(fn, errorInstance, 'Error thrown must be the same errorInstance and have this msg');
    assert.throws(fn, ReferenceError, /Error thrown must be a ReferenceError and match this/);
    assert.throws(fn, errorInstance, /Error thrown must be the same errorInstance and match this/);
    
    Docs
  • const assert = require('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');
    // TypeError [ERR_AMBIGUOUS_ARGUMENT]
    
    // 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]
    Docs
  • const { uri } = await Camera.takePictureAsync();
    const asset = await MediaLibrary.createAssetAsync(uri);
    
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples