Indicates the failure of an assertion. All errors thrown by the node:assert module will be instances of the AssertionError class.

Hierarchy

  • Error
    • AssertionError

Constructors

  • Parameters

    • Optionaloptions: {
          actual?: unknown;
          expected?: unknown;
          message?: string;
          operator?: string;
          stackStartFn?: Function;
      }
      • Optionalactual?: unknown

        The actual property on the error instance.

      • Optionalexpected?: unknown

        The expected property on the error instance.

      • Optionalmessage?: string

        If provided, the error message is set to this value.

      • Optionaloperator?: string

        The operator property on the error instance.

      • OptionalstackStartFn?: Function

        If provided, the generated stack trace omits frames before this function.

    Returns assert.AssertionError

Properties

actual: unknown

Set to the actual argument for methods such as ().

cause?: unknown
code: "ERR_ASSERTION"

Value is always ERR_ASSERTION to show that the error is an assertion error.

expected: unknown

Set to the expected argument for methods such as ().

generatedMessage: boolean

Indicates if the message was auto-generated (true) or not.

message: string
name: string
operator: string

Set to the passed in operator value.

stack?: string
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void