Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ianprime0509/jest-matcher-percent-error
A Jest matcher that tests percent error.
https://github.com/ianprime0509/jest-matcher-percent-error
Last synced: about 2 months ago
JSON representation
A Jest matcher that tests percent error.
- Host: GitHub
- URL: https://github.com/ianprime0509/jest-matcher-percent-error
- Owner: ianprime0509
- License: 0bsd
- Created: 2018-02-11T18:51:37.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-03-18T15:49:56.000Z (10 months ago)
- Last Synced: 2024-11-01T13:08:39.005Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 2.36 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-matcher-percent-error
[![npm](https://img.shields.io/npm/v/jest-matcher-percent-error.svg)](https://www.npmjs.com/package/jest-matcher-percent-error)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ianprime0509/jest-matcher-percent-error/ci.yml?branch=main)This is a simple matcher for [Jest](https://facebook.github.io/jest) that tests
whether the actual value matches the expected value, within some specified
percent error.## Installation
With npm:
```shell
$ npm install --save-dev jest-matcher-percent-error
```## Usage
To test whether the result of `foo()` is within 10% of 100:
```javascript
import toBeWithinPercent from "jest-matcher-percent-error";expect.extend({ toBeWithinPercent });
test("foo works", () => {
expect(foo()).toBeWithinPercent(100, 10);
});
```## License
This is free software, released under the
[Zero Clause BSD License](https://spdx.org/licenses/0BSD.html), as found in the
`LICENSE` file of this repository. This license places no restrictions on your
use, modification, or redistribution of the library: providing attribution is
appreciated, but not required.