jest-matcher-percent-error
v2.0.5
Published
A Jest matcher for testing percent error.
Downloads
7
Maintainers
Readme
jest-matcher-percent-error
This is a simple matcher for Jest that tests whether the actual value matches the expected value, within some specified percent error.
Installation
With npm:
$ npm install --save-dev jest-matcher-percent-error
Usage
To test whether the result of foo()
is within 10% of 100:
import toBeWithinPercent from "jest-matcher-percent-error";
expect.extend({ toBeWithinPercent });
test("foo works", () => {
expect(foo()).toBeWithinPercent(100, 10);
});
License
This is free software, distributed under the MIT license.