1.0.2 • Published 6 years ago

@coderbyheart/jest-expect-tobewithin v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

expect.toBeWithin(number, number)

npm tested with jest Build Status Greenkeeper badge semantic-release Commitizen friendly Standard - JavaScript Style Guide

Use .toBeWithin when you want to check that a number is within a range. For example, if you want to test that ouncesPerCan() returns a value between 5 and 20, write:

test('ounces per can is between 5 and 20', () => {
  expect(ouncesPerCan()).toBeWithin(5, 20);
});

Install

npm i @coderbyheart/jest-expect-tobewithin

Usage

import { toBeWithin } from '@coderbyheart/jest-expect-tobewithin'

expect.extend({toBeWithin});

// In your test:
expect(10).toBeWithin(5,20)