function assertThrows(fn, ErrorClass, msgIncludes = "", msg) {
  let doesThrow = false;
  let error = null;
  try {
    fn();
  } catch (e) {
    if (ErrorClass && !(Object.getPrototypeOf(e) === ErrorClass.prototype)) {
      msg =
        `Expected error to be instance of "${ErrorClass.name}", but was "${e.constructor.name}"${
          msg ? `: ${msg}` : "."
        }`;
      throw new AssertionError(msg);
    }
    if (msgIncludes && !e.message.includes(msgIncludes)) {
      msg =
        `Expected error message to include "${msgIncludes}", but got "${e.message}"${
          msg ? `: ${msg}` : "."
        }`;
      throw new AssertionError(msg);
    }
    doesThrow = true;
    error = e;
  }
  if (!doesThrow) {
    msg = `Expected function to throw${msg ? `: ${msg}` : "."}`;
    throw new AssertionError(msg);
  }
  return error;
}
/** Executes a function, expecting it to throw.  If it does not, then it
 * throws.  An error class and a string that should be included in the
 * error message can also be asserted.
 */
Executes a function, expecting it to throw.  If it does not, then it
throws.  An error class and a string that should be included in the
error message can also be asserted.
Executes a function expecting it to throw . If it does not then it throws . An error class and a string that should be included in the error message can also be asserted .
function assertThrows(fn, ErrorClass, msgIncludes = "", msg) {
  let doesThrow = false;
  let error = null;
  try {
    fn();
  } catch (e) {
    if (ErrorClass && !(Object.getPrototypeOf(e) === ErrorClass.prototype)) {
      msg =
        `Expected error to be instance of "${ErrorClass.name}", but was "${e.constructor.name}"${
          msg ? `: ${msg}` : "."
        }`;
      throw new AssertionError(msg);
    }
    if (msgIncludes && !e.message.includes(msgIncludes)) {
      msg =
        `Expected error message to include "${msgIncludes}", but got "${e.message}"${
          msg ? `: ${msg}` : "."
        }`;
      throw new AssertionError(msg);
    }
    doesThrow = true;
    error = e;
  }
  if (!doesThrow) {
    msg = `Expected function to throw${msg ? `: ${msg}` : "."}`;
    throw new AssertionError(msg);
  }
  return error;
}
function assertThrows ( fn , ErrorClass , msgIncludes = "" , msg ) { let doesThrow = false ; let error = null ; try { fn ( ) ; } catch ( e ) { if ( ErrorClass && ! ( Object . getPrototypeOf ( e ) === ErrorClass . prototype ) ) { msg = ` ${ ErrorClass . name } ${ e . constructor . name } ${ msg ? ` ${ msg } ` : "." } ` ; throw new AssertionError ( msg ) ; } if ( msgIncludes && ! e . message . includes ( msgIncludes ) ) { msg = ` ${ msgIncludes } ${ e . message } ${ msg ? ` ${ msg } ` : "." } ` ; throw new AssertionError ( msg ) ; } doesThrow = true ; error = e ; } if ( ! doesThrow ) { msg = ` ${ msg ? ` ${ msg } ` : "." } ` ; throw new AssertionError ( msg ) ; } return error ; }
Executes a function, expecting it to throw.
Executes a function expecting it to throw .