1. jest-matcher-deep-close-to
Extend jest to assert arrays with approximate values
jest-matcher-deep-close-to
Package: jest-matcher-deep-close-to
Created by: maasencioh
Last modified: Fri, 06 May 2022 12:33:39 GMT
Version: 3.0.2
License: MIT
Downloads: 62,952
Repository: https://github.com/maasencioh/jest-matcher-deep-close-to

Install

npm install jest-matcher-deep-close-to
yarn add jest-matcher-deep-close-to

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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin