The expect
function is used every time you want to test a value.
You will rarely call expect
by itself.
The value to apply matchers against.
Adds a module to format application-specific data structures for serialization.
Matches anything that was created with the given constructor.
You can use it inside toEqual
or toBeCalledWith
instead of a literal value.
Matches anything but null or undefined. You can use it inside toEqual
or toBeCalledWith
instead
of a literal value. For example, if you want to check that a mock function is called with a
non-null argument:
Matches any array made up entirely of elements in the provided array.
You can use it inside toEqual
or toBeCalledWith
instead of a literal value.
Optionally, you can provide a type for the elements via a generic.
Verifies that a certain number of assertions are called during a test. This is often useful when testing asynchronous code, in order to make sure that assertions in a callback actually got called.
You can use expect.extend
to add your own matchers to Jest.
Verifies that at least one assertion is called during a test. This is often useful when testing asynchronous code, in order to make sure that assertions in a callback actually got called.
Matches any object that recursively matches the provided keys. This is often handy in conjunction with other asymmetric matchers.
Optionally, you can provide a type for the object via a generic. This ensures that the object contains the desired structure.
Matches any received string that contains the exact expected string
Matches any string that contains the exact provided string
The
expect
function is used every time you want to test a value. You will rarely callexpect
by itself.