jest-matcher-deep-close-to
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

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

Package Sidebar

Install

npm i jest-matcher-deep-close-to

Weekly Downloads

18,750

Version

3.0.2

License

MIT

Unpacked Size

49.4 kB

Total Files

21

Last publish

Collaborators

  • maasencioh