Go to repository

Interface Expectation<T>

This type represents an expectation for any type of element. The matchers that can be called contain general things, such as strict comparison with other elements, be undefined, be null, or any other checks.

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 Expectation<T> & FinishedExpectation

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

Returns Expectation<T> & FinishedExpectation

Answers if the actual value is a falsy value.

Returns Expectation<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 Expectation<T> & FinishedExpectation

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

Returns Expectation<T> & FinishedExpectation

Answers if the actual value is a truthy value.

Returns Expectation<T> & FinishedExpectation

Answers if the actual value is undefined.

Returns Expectation<T> & FinishedExpectation

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

Parameters

  • shape: Shape

Returns Expectation<T> & FinishedExpectation

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

Parameters

  • value: string

Returns Expectation<T> & FinishedExpectation

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