Go to repository

Interface ObjectExpectation<T>

This interface represents an expectation that is performed over an object.

Type Parameters

  • T

Hierarchy (view full)

Properties

This attribute retrieves an expectancy whose result value is false in case the matcher fulfills, and true otherwise.

Methods

Answer the given expectation as an instance of IArrayExpectation. No check is performed on the input to see if it can actually be casted.

Type Parameters

  • E

Returns ArrayExpectation<E>

Answer the given expectation as an instance of INumberExpectation. No check is performed on the input to see if it can actually be casted.

Returns NumberExpectation

Answer the given expectation as an instance of IObjectExpectation. No check is performed on the input to see if it can actually be casted.

Type Parameters

  • E

Returns ObjectExpectation<E>

Answer the given expectation as an instance of IStringExpectation. No check is performed on the input to see if it can actually be casted.

Returns StringExpectation

Answers if the actual value is the same as expected, using strict compare. Do not use toBe with floating point numbers, use Expectations/Matchers.toBeCloseTo instead.

Parameters

  • value: T

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value is defined (as in not equal to undefined)

Returns ObjectExpectation<T> & FinishedExpectation

Answer if the actual element is empty.

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value is a falsy value.

Returns ObjectExpectation<T> & FinishedExpectation

Answer if the actual element is an instance of a given class (using instanceof).

Parameters

  • classConstructor: ((...arguments_: readonly unknown[]) => unknown)
      • (...arguments_): unknown
      • Parameters

        • Rest
          ...arguments_: readonly unknown[]

        Returns unknown

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value is the same as expected, using a deep compare mechanism. Do not use toBeLike with floating point numbers, use Expectations/Matchers.toBeCloseTo instead.

Parameters

  • value: T

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value is null (strict null, not undefined).

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value is a truthy value.

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value is undefined.

Returns ObjectExpectation<T> & FinishedExpectation

Answer if an object has at least all keys in the least. Combine with toHaveNoOtherThan to ensure exact key existence

Parameters

  • keys: string[]

Returns ObjectExpectation<T> & FinishedExpectation

Answer if an object has no other than the given keys (although not all given need to be present). Combine with toHaveAtLeast to ensure exact key existence

Parameters

  • keys: string[]

Returns ObjectExpectation<T> & FinishedExpectation

Answer if the actual element has a property with the given name.

Parameters

  • propertyName: string

Returns ObjectExpectation<T> & FinishedExpectation

Answer if the actual element has the given amount of properties.

Parameters

  • count: number

Returns ObjectExpectation<T> & FinishedExpectation

Answer if the actual element has the given shape, as defined by the shapeOf submodule.

Parameters

  • shape: Shape

Returns ObjectExpectation<T> & FinishedExpectation

Answers if the actual value has a type matching the expected type, checked by using the typeof operator.

Parameters

  • value: string

Returns ObjectExpectation<T> & FinishedExpectation

`toHaveType('hello', 'string')` returns `true`.
""