code: function assertError(result, error) {
    if (typeof error === 'function') {
      if (!(result instanceof error || error(result) === true)) {
        throw result
      }
    } else if (typeof error === 'string') {
      assert(result.message.includes(error), 'Error message is incorrect')
    } else if (error instanceof RegExp) {
      assert(
        error.test(result.message),
        `Expected ${result.message} to match ${error}`,
      )
    } else {
      invariant(
        typeof error === 'boolean',
        'The given `error` must be a function, string, boolean, or RegExp',
      )
    }
  }
docs: eslint-disable-next-line complexity