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 after date.

            Parameter date

          method toBeAfterOrEqualTo

          toBeAfterOrEqualTo: (date: Date) => R;
          • Use .toBeAfterOrEqualTo when checking if a date equals to or occurs after date.

            Parameter date

          method toBeArray

          toBeArray: () => R;
          • Use .toBeArray when checking if a value is an Array.

          method toBeArrayOfSize

          toBeArrayOfSize: (x: number) => R;
          • Use .toBeArrayOfSize when checking if a value is an Array of size x.

            Parameter x

          method toBeBefore

          toBeBefore: (date: Date) => R;
          • Use .toBeBefore when checking if a date occurs before date.

            Parameter date

          method toBeBeforeOrEqualTo

          toBeBeforeOrEqualTo: (date: Date) => R;
          • Use .toBeBeforeOrEqualTo when checking if a date equals to or occurs before date.

            Parameter date

          method toBeBetween

          toBeBetween: (startDate: Date, endDate: Date) => R;
          • Use .toBeBetween when checking if a date occurs between startDate and endDate.

            Parameter startDate

            Parameter endDate

          method toBeBoolean

          toBeBoolean: () => R;
          • Use .toBeBoolean when checking if a value is a Boolean.

          method toBeDate

          toBeDate: () => R;
          • Use .toBeDate when checking if a value is a Date.

          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 empty Object.

          method toBeEven

          toBeEven: () => R;
          • Use .toBeEven when checking if a value is an even Number.

          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 (===) to false.

          method toBeFinite

          toBeFinite: () => R;
          • Use .toBeFinite when checking if a value is a Number, not NaN or Infinity.

          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 a Function.

          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 is NaN.

          method toBeNegative

          toBeNegative: () => R;
          • Use .toBeNegative when checking if a value is a negative Number.

          method toBeNil

          toBeNil: () => R;
          • Use .toBeNil when checking a value is null or undefined.

          method toBeNumber

          toBeNumber: () => R;
          • Use .toBeNumber when checking if a value is a Number.

          method toBeObject

          toBeObject: () => R;
          • Use .toBeObject when checking if a value is an Object.

          method toBeOdd

          toBeOdd: () => R;
          • Use .toBeOdd when checking if a value is an odd Number.

          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 positive Number.

          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 a String.

          method toBeSymbol

          toBeSymbol: () => R;
          • Use .toBeSymbol when checking if a value is a Symbol.

          method toBeTrue

          toBeTrue: () => R;
          • Use .toBeTrue when checking a value is equal (===) to true.

          method toBeValidDate

          toBeValidDate: () => R;
          • Use .toBeValidDate when checking if a value is a valid 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 a String ends with a given String 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 a String is equal (===) to given String ignoring white-space.

            Parameter string

          method toHaveBeenCalledAfter

          toHaveBeenCalledAfter: (
          mock: jest.MockInstance<any, any[]>,
          failIfNoFirstInvocation?: boolean
          ) => R;
          • Use .toHaveBeenCalledAfter when checking if a Mock was called after another Mock.

            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 a Mock was called before another Mock.

            Note: Required Jest version >=23

            Parameter mock

            Parameter failIfNoSecondInvocation

          method toHaveBeenCalledExactlyOnceWith

          toHaveBeenCalledExactlyOnceWith: (...args: unknown[]) => R;
          • Use .toHaveBeenCalledExactlyOnceWith to check if a Mock was called exactly one time with the expected value.

          method toHaveBeenCalledOnce

          toHaveBeenCalledOnce: () => R;
          • Use .toHaveBeenCalledOnce to check if a Mock was called exactly one time.

          method toInclude

          toInclude: (substring: string) => R;
          • Use .toInclude when checking if a String includes the given String substring.

            Parameter substring

          method toIncludeAllMembers

          toIncludeAllMembers: <E = unknown>(members: readonly E[]) => R;
          • Use .toIncludeAllMembers when checking if an Array 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 an Array 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 an Array contains any of the members of a given set.

            Parameter members

          method toIncludeMultiple

          toIncludeMultiple: (substring: readonly string[]) => R;
          • Use .toIncludeMultiple when checking if a String includes all of the given substrings.

            Parameter substring

          method toIncludeRepeated

          toIncludeRepeated: (substring: string, times: number) => R;
          • Use .toIncludeRepeated when checking if a String includes the given String 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 a Boolean.

            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 a Boolean 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 returns true for any matching value in an array.

            Parameter predicate

          method toStartWith

          toStartWith: (prefix: string) => R;
          • Use .toStartWith when checking if a String starts with a given String 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)

              Peer Dependencies (1)

              Badge

              To add a badge like this onejsDocs.io badgeto 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>