jest-extended
- Version 4.0.2
- Published
- 107 kB
- 2 dependencies
- MIT license
Install
npm i jest-extended
yarn add jest-extended
pnpm add jest-extended
Overview
Additional Jest matchers
Index
Namespaces
namespace jest
namespace jest {}
interface Expect
interface Expect extends CustomMatchers<any> {}
interface InverseAsymmetricMatchers
interface InverseAsymmetricMatchers extends Expect {}
interface Matchers
interface Matchers<R> {}
method fail
fail: (message: string) => never;
Note: Currently unimplemented Failing assertion
Parameter message
method pass
pass: (message: string) => R;
Note: Currently unimplemented Passing assertion
Parameter message
method toBeAfter
toBeAfter: (date: Date) => R;
Use
.toBeAfter
when checking if a date occurs afterdate
.Parameter date
method toBeAfterOrEqualTo
toBeAfterOrEqualTo: (date: Date) => R;
Use
.toBeAfterOrEqualTo
when checking if a date equals to or occurs afterdate
.Parameter date
method toBeArray
toBeArray: () => R;
Use
.toBeArray
when checking if a value is anArray
.
method toBeArrayOfSize
toBeArrayOfSize: (x: number) => R;
Use
.toBeArrayOfSize
when checking if a value is anArray
of size x.Parameter x
method toBeBefore
toBeBefore: (date: Date) => R;
Use
.toBeBefore
when checking if a date occurs beforedate
.Parameter date
method toBeBeforeOrEqualTo
toBeBeforeOrEqualTo: (date: Date) => R;
Use
.toBeBeforeOrEqualTo
when checking if a date equals to or occurs beforedate
.Parameter date
method toBeBetween
toBeBetween: (startDate: Date, endDate: Date) => R;
Use
.toBeBetween
when checking if a date occurs betweenstartDate
andendDate
.Parameter startDate
Parameter endDate
method toBeBoolean
toBeBoolean: () => R;
Use
.toBeBoolean
when checking if a value is aBoolean
.
method toBeDate
toBeDate: () => R;
Use
.toBeDate
when checking if a value is aDate
.
method toBeDateString
toBeDateString: () => R;
Use
.toBeDateString
when checking if a value is a valid date string.
method toBeEmpty
toBeEmpty: () => R;
Use .toBeEmpty when checking if a String '', Array [], Object {} or Iterable (i.e. Map, Set) is empty.
method toBeEmptyObject
toBeEmptyObject: () => R;
Use
.toBeEmptyObject
when checking if a value is an emptyObject
.
method toBeEven
toBeEven: () => R;
Use
.toBeEven
when checking if a value is an evenNumber
.
method toBeExtensible
toBeExtensible: () => R;
Use
.toBeExtensible
when checking if an object is extensible.
method toBeFalse
toBeFalse: () => R;
Use
.toBeFalse
when checking a value is equal (===) tofalse
.
method toBeFinite
toBeFinite: () => R;
Use
.toBeFinite
when checking if a value is aNumber
, notNaN
orInfinity
.
method toBeFrozen
toBeFrozen: () => R;
Use
.toBeFrozen
when checking if an object is frozen.
method toBeFunction
toBeFunction: () => R;
Use
.toBeFunction
when checking if a value is aFunction
.
method toBeHexadecimal
toBeHexadecimal: () => R;
Use
.toBeHexadecimal
when checking if a value is a valid HTML hex color.
method toBeInRange
toBeInRange: (min: number, max: number) => R;
Use
.toBeInRange
when checking if an array has elements in range min (inclusive) and max (inclusive).Parameter min
Parameter max
method toBeInteger
toBeInteger: () => R;
Use
.toBeInteger
when checking if a value is an integer.
method toBeNaN
toBeNaN: () => R;
Use
.toBeNaN
when checking a value isNaN
.
method toBeNegative
toBeNegative: () => R;
Use
.toBeNegative
when checking if a value is a negativeNumber
.
method toBeNil
toBeNil: () => R;
Use
.toBeNil
when checking a value isnull
orundefined
.
method toBeNumber
toBeNumber: () => R;
Use
.toBeNumber
when checking if a value is aNumber
.
method toBeObject
toBeObject: () => R;
Use
.toBeObject
when checking if a value is anObject
.
method toBeOdd
toBeOdd: () => R;
Use
.toBeOdd
when checking if a value is an oddNumber
.
method toBeOneOf
toBeOneOf: <E = unknown>(members: readonly E[]) => R;
Use .toBeOneOf when checking if a value is a member of a given Array.
Parameter members
method toBePositive
toBePositive: () => R;
Use
.toBePositive
when checking if a value is a positiveNumber
.
method toBeSealed
toBeSealed: () => R;
Use
.toBeSealed
when checking if an object is sealed.
method toBeString
toBeString: () => R;
Use
.toBeString
when checking if a value is aString
.
method toBeSymbol
toBeSymbol: () => R;
Use
.toBeSymbol
when checking if a value is aSymbol
.
method toBeTrue
toBeTrue: () => R;
Use
.toBeTrue
when checking a value is equal (===) totrue
.
method toBeValidDate
toBeValidDate: () => R;
Use
.toBeValidDate
when checking if a value is avalid Date
.
method toBeWithin
toBeWithin: (start: number, end: number) => R;
Use
.toBeWithin
when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive).Parameter start
Parameter end
method toContainAllEntries
toContainAllEntries: <E = unknown>( entries: readonly (readonly [keyof E, E[keyof E]])[]) => R;
Use
.toContainAllEntries
when checking if an object only contains all of the provided entries.Parameter entries
method toContainAllKeys
toContainAllKeys: <E = unknown>(keys: readonly (keyof E | string)[]) => R;
Use
.toContainAllKeys
when checking if an object only contains all of the provided keys.Parameter keys
method toContainAllValues
toContainAllValues: <E = unknown>(values: readonly E[]) => R;
Use
.toContainAllValues
when checking if an object only contains all of the provided values.Parameter values
method toContainAnyEntries
toContainAnyEntries: <E = unknown>( entries: readonly (readonly [keyof E, E[keyof E]])[]) => R;
Use
.toContainAnyEntries
when checking if an object contains at least one of the provided entries.Parameter entries
method toContainAnyKeys
toContainAnyKeys: <E = unknown>(keys: readonly (keyof E | string)[]) => R;
Use
.toContainAnyKeys
when checking if an object contains at least one of the provided keys.Parameter keys
method toContainAnyValues
toContainAnyValues: <E = unknown>(values: readonly E[]) => R;
Use
.toContainAnyValues
when checking if an object contains at least one of the provided values.Parameter values
method toContainEntries
toContainEntries: <E = unknown>( entries: readonly (readonly [keyof E, E[keyof E]])[]) => R;
Use
.toContainEntries
when checking if an object contains all of the provided entries.Parameter entries
method toContainEntry
toContainEntry: <E = unknown>(entry: readonly [keyof E, E[keyof E]]) => R;
Use
.toContainEntry
when checking if an object contains the provided entry.Parameter entry
method toContainKey
toContainKey: <E = unknown>(key: keyof E | string) => R;
Use
.toContainKey
when checking if an object contains the provided key.Parameter key
method toContainKeys
toContainKeys: <E = unknown>(keys: readonly (keyof E | string)[]) => R;
Use
.toContainKeys
when checking if an object has all of the provided keys.Parameter keys
method toContainValue
toContainValue: <E = unknown>(value: E) => R;
Use
.toContainValue
when checking if an object contains the provided value.Parameter value
method toContainValues
toContainValues: <E = unknown>(values: readonly E[]) => R;
Use
.toContainValues
when checking if an object contains all of the provided values.Parameter values
method toEndWith
toEndWith: (suffix: string) => R;
Use
.toEndWith
when checking if aString
ends with a givenString
suffix.Parameter suffix
method toEqualCaseInsensitive
toEqualCaseInsensitive: (string: string) => R;
Use
.toEqualCaseInsensitive
when checking if a string is equal (===) to another ignoring the casing of both strings.Parameter string
method toEqualIgnoringWhitespace
toEqualIgnoringWhitespace: (string: string) => R;
Use
.toEqualIgnoringWhitespace
when checking if aString
is equal (===) to givenString
ignoring white-space.Parameter string
method toHaveBeenCalledAfter
toHaveBeenCalledAfter: ( mock: jest.MockInstance<any, any[]>, failIfNoFirstInvocation?: boolean) => R;
Use
.toHaveBeenCalledAfter
when checking if aMock
was called after anotherMock
.Note: Required Jest version >=23
Parameter mock
Parameter failIfNoFirstInvocation
method toHaveBeenCalledBefore
toHaveBeenCalledBefore: ( mock: jest.MockInstance<any, any[]>, failIfNoSecondInvocation?: boolean) => R;
Use
.toHaveBeenCalledBefore
when checking if aMock
was called before anotherMock
.Note: Required Jest version >=23
Parameter mock
Parameter failIfNoSecondInvocation
method toHaveBeenCalledExactlyOnceWith
toHaveBeenCalledExactlyOnceWith: (...args: unknown[]) => R;
Use
.toHaveBeenCalledExactlyOnceWith
to check if aMock
was called exactly one time with the expected value.
method toHaveBeenCalledOnce
toHaveBeenCalledOnce: () => R;
Use
.toHaveBeenCalledOnce
to check if aMock
was called exactly one time.
method toInclude
toInclude: (substring: string) => R;
Use
.toInclude
when checking if aString
includes the givenString
substring.Parameter substring
method toIncludeAllMembers
toIncludeAllMembers: <E = unknown>(members: readonly E[]) => R;
Use
.toIncludeAllMembers
when checking if anArray
contains all of the same members of a given set.Parameter members
method toIncludeAllPartialMembers
toIncludeAllPartialMembers: <E = unknown>(members: readonly E[]) => R;
Use
.toIncludeAllPartialMembers
when checking if anArray
contains all of the same partial members of a given set.Parameter members
method toIncludeAnyMembers
toIncludeAnyMembers: <E = unknown>(members: readonly E[]) => R;
Use
.toIncludeAnyMembers
when checking if anArray
contains any of the members of a given set.Parameter members
method toIncludeMultiple
toIncludeMultiple: (substring: readonly string[]) => R;
Use
.toIncludeMultiple
when checking if aString
includes all of the given substrings.Parameter substring
method toIncludeRepeated
toIncludeRepeated: (substring: string, times: number) => R;
Use
.toIncludeRepeated
when checking if aString
includes the givenString
substring the correct number of times.Parameter substring
Parameter times
method toIncludeSameMembers
toIncludeSameMembers: <E = unknown>(members: readonly E[]) => R;
Use
.toIncludeSameMembers
when checking if two arrays contain equal values, in any order.Parameter members
method toPartiallyContain
toPartiallyContain: <E = unknown>(member: E) => R;
Use
.toPartiallyContain
when checking if any array value matches the partial member.Parameter member
method toReject
toReject: () => Promise<R>;
Use
.toReject
when checking if a promise rejects.
method toResolve
toResolve: () => Promise<R>;
Use
.toResolve
when checking if a promise resolves.
method toSatisfy
toSatisfy: <E = any>(predicate: (x: E) => boolean) => R;
Use
.toSatisfy
when you want to use a custom matcher by supplying a predicate function that returns aBoolean
.Parameter predicate
method toSatisfyAll
toSatisfyAll: <E = any>(predicate: (x: E) => boolean) => R;
Use
.toSatisfyAll
when you want to use a custom matcher by supplying a predicate function that returns aBoolean
for all values in an array.Parameter predicate
method toSatisfyAny
toSatisfyAny: (predicate: (x: any) => boolean) => R;
Use
.toSatisfyAny
when you want to use a custom matcher by supplying a predicate function that returnstrue
for any matching value in an array.Parameter predicate
method toStartWith
toStartWith: (prefix: string) => R;
Use
.toStartWith
when checking if aString
starts with a givenString
prefix.Parameter prefix
method toThrowWithMessage
toThrowWithMessage: ( type: | (new (...args: any[]) => { message: string }) | (abstract new (...args: any[]) => { message: string }) | ((...args: any[]) => { message: string }), message: string | RegExp) => R;
Use
.toThrowWithMessage
when checking if a callback function throws an error of a given type with a given error message.Parameter type
Parameter message
namespace jest-extended
module 'jest-extended' {}
variable matchers
const matchers: CustomMatchers<any>;
Package Files (1)
Dependencies (2)
Dev Dependencies (23)
- @babel/cli
- @babel/core
- @babel/preset-env
- @changesets/cli
- @jest/expect-utils
- @types/jest
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- babel-jest
- babel-jest-assertions
- eslint
- eslint-config-prettier
- eslint-import-resolver-typescript
- eslint-plugin-import
- eslint-plugin-jest
- eslint-plugin-prettier
- husky
- jest
- jest-serializer-ansi-escapes
- jest-watch-typeahead
- lint-staged
- prettier
- typescript
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/jest-extended
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/jest-extended)
- HTML<a href="https://www.jsdocs.io/package/jest-extended"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4205 ms. - Missing or incorrect documentation? Open an issue for this package.