28.1.1 • Published 4 months ago

@kayahr/jest-matchers v28.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 months ago

jest-matchers

Some additional Jest matchers I usually use in my projects.

Usage

  • Install dependency:

    npm install --dev @kayahr/jest-matchers
  • Import it in your Jest test file:

    @import "@kayahr/jest-matchers";

Matchers

toEqualCloseTo(value, numDigits?)

Recursive version of toBeCloseTo() so you can compare arrays or objects with numeric values with a specific precision. numDigits defaults to 2 if not specified.

expect(values).toEqualCloseTo([ 10.3132, 40.1224, 50.1311 ], 4);

toBeEquatable(equalValues, unequalValues)

Checks if the tested object has an equals method which correctly implements an equivalence relation on non-null object references (See Java's object.equals() method for details).

expect(new Color(0, 0, 0)).toBeEquatable(
    [ new Color(0, 0, 0), new Color("black") ],
    [ new Color(1, 0, 0), new Color(0, 1, 0), new Color(0, 0, 1), new Color("white") ]
);
28.1.1

4 months ago

28.1.0

12 months ago

28.0.0

2 years ago

1.0.2

2 years ago

1.0.1

3 years ago

1.0.0

4 years ago