Constructors

Properties

#pendingEmits: ExpectedEmit[] = []
#setOnBeforeEnd: boolean = false

Methods

Assertion Methods

  • Returns the error object if it throws and that does not fail the test (by virtue of being marked skip or todo). Otherwise returns the passing status, like other assertions.

    Parameters

    • fn: Function | (() => any)
    • Rest ...__namedParameters: MessageExtra

    Returns boolean | Error

  • Asserts that the emitter emits the specified event before the test ends. Returns a promise that resolves when the event is emitted. Note that waiting on the returned promise within a test can deadlock the test, if the event never emits, but the returned promise can be a handy way to pause a test until an event happens, if you are reasonably confident that it will fire.

    Parameters

    • emitter: EventTarget | EventEmitter<DefaultEventMap>
    • event: string
    • Rest ...__namedParameters: MessageExtra

    Returns Promise<void>

  • Verify that the values are equal

    Type Parameters

    • T extends unknown

    Parameters

    Returns found is T

  • Verify that the object has all of the properties and values in the pattern, matching loosely.

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the object has the wanted property, using Object#hasOwnProperty

    Type Parameters

    • T extends {}

    Parameters

    • found: T
    • wanted: string | number | symbol
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the object has all of the properties listed in the wanted list, using Object#hasOwnProperties()

    Type Parameters

    • T extends {}

    Parameters

    • found: T
    • wanted: Iterable<string | number | symbol>
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the object has all of the properties listed in the wanted list, using Object#hasOwnProperties(), and no others

    Type Parameters

    • T extends {}

    Parameters

    • found: T
    • wanted: Iterable<string | number | symbol>
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the object has the wanted property, anywhere in its prototype chain.

    Type Parameters

    • T extends {}

    Parameters

    • found: T
    • wanted: string | number | symbol
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the object has all of the properties in the wanted list, anywhere in its prototype chain.

    Type Parameters

    • T extends {}

    Parameters

    • found: T
    • wanted: Iterable<string | number | symbol>
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value has all of the properties and values in the pattern, matching strictly.

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value matches the pattern provided

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value matches the pattern provided, with no extra properties.

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value matches the pattern provided, with no extra properties.

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value matches the pattern provided, but fail if any fields only match via type coercion.

    For example,

    t.matchStrict({ a: 1 }, { a: Number }, 'this passes')
    t.matchStrict({ a: 1 }, { a: '1' }, 'this fails')

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the values are not equal

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the object does NOT have all of the properties and values in the pattern, matching loosely.

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value does NOT contain all of the properties and values in the test pattern, comparing strictly.

    Note that this will pass if the value has some of the listed properties, or if they do not match the same type.

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value does NOT match the pattern provided.

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value does not match the pattern provided, with no extra properties. Ie, it might either not match, or have extra props.

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value does not match the pattern provided, with no extra properties. Ie, it might either not match, or have extra props.

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value does not match the pattern provided, without type coercion.

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value is not truthy

    Parameters

    Returns boolean

  • Verify that the value is not loosely equivalent to the supplied pattern

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • resolves to the error object rejected if it rejects as expected, 'false' if it does not, or 'true' if it fails to reject but is marked as skip/todo.

    Type Parameters

    • T extends unknown = any

    Parameters

    • fnOrPromise: Promise<T> | (() => Promise<T>)
    • Rest ...__namedParameters: ThrowsArgs

    Returns Promise<boolean | Error>

  • Test the resolved promise result with t.match()

    Resolves to true if it passes, false if the promise rejects or the match fails, or the rejection error value if the promise rejects but the assertion passes by being marked todo/skip.

    Type Parameters

    • T extends unknown = any

    Parameters

    • fnOrPromise: Promise<T> | (() => Promise<T>)
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns Promise<boolean>

  • Resolves to 'true' if the promise resolves successfully, 'false' if it rejects and fails, or the rejection error if it rejects but the failure is accepted by by being marked todo or skip

    Type Parameters

    • T extends unknown = any

    Parameters

    • fnOrPromise: Promise<T> | (() => Promise<T>)
    • Rest ...__namedParameters: MessageExtra

    Returns Promise<boolean | Error>

  • Verify that the value is loosely equivalent to the supplied pattern

    Parameters

    • found: any
    • wanted: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value is not strictly equivalent to the supplied pattern object

    Parameters

    • found: any
    • doNotWant: any
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

  • Verify that the value is strictly equivalent to the supplied pattern

    Type Parameters

    • T extends unknown

    Parameters

    Returns found is T

  • Verify that the function throws an error. Thrown error is tested against the wanted param if provided, using t.match().

    Returns false on failure, or the error object thrown on success

    Parameters

    • fn: Function | (() => any)
    • Rest ...__namedParameters: ThrowsArgs

    Returns boolean | Error

  • Verify that the value is of the type specified Type can be either a string, or a constructor.

    If a string, then it can match either the typeof result or 'null' for null values, or the name property of the object's constructor.

    Parameters

    • obj: any
    • klass: string | Function
    • Rest ...__namedParameters: MessageExtra

    Returns boolean

Generated using TypeDoc