jest-matcher-deep-close-to

Extend jest to assert arrays with approximate values


Keywords
jest, jest-tests, jest-matchers, arrays, hacktoberfest
License
MIT
Install
npm install jest-matcher-deep-close-to@3.0.2

Documentation

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