Package detail

jest-matcher-deep-close-to

maasencioh105.3kMIT3.0.2

Extend jest to assert arrays with approximate values

jest, jest-tests, jest-matchers, arrays

readme

jest-matcher-deep-close-to

NPM version build status npm download

Extend jest to assert arrays and objects with approximate values.

Installation

$ npm i -D jest-matcher-deep-close-to

Usage

import {toBeDeepCloseTo,toMatchCloseTo} from 'jest-matcher-deep-close-to';
expect.extend({toBeDeepCloseTo, toMatchCloseTo});

describe('test myModule', () => {
    it('should return 42', () => {
        expect([42.0003]).toBeDeepCloseTo([42.0004], 3);
    });
});

describe('test myModule', () => {
    it('should return 42', () => {
        expect({ foo: 42.0003,  bar: "xxx", baz: "yyy"})
            .toMatchCloseTo({ foo: 42.004, bar: "xxx" }, 3);
    });
});

License

MIT

changelog

Changelog

3.0.2 (2021-10-08)

Bug Fixes

  • package: run prepublish script in sequence (#34) (77f1dbf)

3.0.1 (2021-10-07)

Bug Fixes

  • print correct diff in error message (896ccad)
  • typings: include Jest extensions from lib's entrypoint (9b76880)

3.0.0 (2021-09-28)

⚠ BREAKING CHANGES

  • changes the precision from 110^-x to be 510^-(x+1)

Features

  • format response similar to jest-closeTo (bfcef08)
  • support typed arrays (b43349a), closes #20

Bug Fixes

Miscellaneous Chores

  • update default precision from jest-closeTo (880d084), closes #23