jest-matcher-deep-close-to
v3.0.2
Published
Extend jest to assert arrays with approximate values
Downloads
98,609
Maintainers
Readme
jest-matcher-deep-close-to
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);
});
});