@srijs/hedgehog
v0.1.5
Published
Hedgehog will eat all your bugs.
Downloads
8
Readme
hedgehog
Hedgehog is a modern property-based testing library.
It helps you write tests that catch more bugs with less code, are easier to write and to maintain.
You can use Hedgehog together with Mocha, Jest, and many other testing frameworks.
Installation
Hedgehog is available via npm
.
npm install @srijs/hedgehog
Usage
Just use your favorite testing framework, and sprinkle in some forAll
goodness:
import {forAll, Gen, Range} from '@srijs/hedgehog';
describe('arrays', () => {
it('does not matter when an array is reversed twice', () => forAll({
// Generate an array of booleans, with a length between 0 and 100.
array: Gen.boolean().array(Range.linear(0, 100))
}, ({array}) => {
// Shallow copy the array and reverse it twice.
const reversed = array.slice().reverse().reverse();
// Compare it to the original array.
expect(reversed).toEqual(array);
}));
});
Todo
- [ ] Performance tuning
- [ ] Randomness tests (uniformity, etc)
License
MIT