fp-ts-test
fp-ts port of Haskell's QuickCheck.
NOTE
Please note that shrinking is exposed, but not used in the assertions.
When used in the assertions, this library will be ready for production use.
Features
Installation
yarn add -D fp-ts-quickcheck
Quick Start
Grab your favourite test library, in this case jest
, and put the assertion call of this library into the test caller.
export function add(x: number, y: number) {
return x + y
}
import { quickcheck, arbitrary } from "fp-ts-quickcheck"
import { expect, it, describe } from "@jest/globals"
import { pipe } from "fp-ts/function"
describe(add, () => {
const numnum = arbitrary.tuple(arbitraty.int(), arbitrary.int())
it("should be an associative operation", () => {
quickcheck.sync(numnum, ([x, y]) => add(y, x) === add(x, y))
})
it("should be an associative operation", () => {
quickcheck.sync(numnum, ([x, y]) => {
expect(add(x, y)).toBe(add(y, x))
})
})
})