@srijs/hedgehog
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

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.

CircleCI npm (scoped) Codecov Greenkeeper badge

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

Readme

Keywords

none

Package Sidebar

Install

npm i @srijs/hedgehog

Weekly Downloads

2

Version

0.1.5

License

MIT

Last publish

Collaborators

  • srijs