Skip to content

Extending Jestspectation

JestspectationBase

Base class of types used in Jestspectation.

get_contents_repr()

Returns a list of string representations for the inner contents.

These strings are considered to be individual tokens, and are used to shorten the __repr__ string of Jestspectation matchers by replacing excess items with an ellipsis (...).

This method should be implemented if the __repr__ method is not overridden.

Returns:

Type Description
list[str]

list[str]: inner contents

get_contents_repr_edges()

Returns the opening and closing tokens to surround the contents with.

This is used to build the representation of Jestspectation matchers from a list of contents gathered from the get_contents_repr method.

This method should be implemented if the __repr__ method is not overridden.

get_diff(other, other_is_lhs) abstractmethod

Returns a list of strings showing the difference between this and some other object. Each string represents a single line of output.

This function expects that the two objects have already been checked and are not equal.

Parameters:

Name Type Description Default
other object

object to compare

required
other_is_lhs bool

whether the other object is on the left hand side of the expression

required

Returns:

Type Description
list[str]

Optional[list[str]]: difference