How to use the AssertionError function from assert

Find comprehensive JavaScript assert.AssertionError code examples handpicked from public code repositorys.

269
270
271
272
273
274
275
276
277
278
279
280
281
// assert module must conform to the following interface.


var assert = module.exports = ok;


// 2. The AssertionError is defined in assert.
// new assert.AssertionError({ message: message,
//                             actual: actual,
//                             expected: expected })


assert.AssertionError = function AssertionError(options) {
fork icon11
star icon21
watch icon6

+ 3 other calls in file

477
478
479
480
481
482
483
484
485
486
{
  // Bad args to AssertionError constructor should throw TypeError.
  const args = [1, true, false, '', null, Infinity, Symbol('test'), undefined];
  args.forEach((input) => {
    assert.throws(
      () => new assert.AssertionError(input),
      {
        code: 'ERR_INVALID_ARG_TYPE',
        name: 'TypeError',
        message: 'The "options" argument must be of type object.' +
fork icon0
star icon0
watch icon0

+ 2 other calls in file