@fast-check/jest
Version:
Property based testing for Jest based on fast-check
19 lines (18 loc) • 1.06 kB
TypeScript
import { Arbitrary, Parameters, readConfigureGlobal } from "fast-check";
import { it } from "@jest/globals";
//#region src/internals/types.d.ts
type It = typeof it;
type ArbitraryTuple<Ts extends [any] | any[]> = { [P in keyof Ts]: Arbitrary<Ts[P]> };
type ArbitraryRecord<Ts> = { [P in keyof Ts]: Arbitrary<Ts[P]> };
type Prop<Ts extends [any] | any[]> = (...args: Ts) => boolean | void | PromiseLike<boolean | void>;
type PropRecord<Ts> = (arg: Ts) => boolean | void | PromiseLike<boolean | void>;
//#endregion
//#region src/internals/TestBuilder.d.ts
/**
* Revamped {it,test} with added `.prop`
*/
type FastCheckItBuilder<T> = T & ("each" extends keyof T ? T & {
prop: <Ts, TsParameters extends Ts = Ts>(arbitraries: Ts extends [any] | any[] ? ArbitraryTuple<Ts> : ArbitraryRecord<Ts>, params?: Parameters<TsParameters>) => (testName: string, prop: Ts extends [any] | any[] ? Prop<Ts> : PropRecord<Ts>, timeout?: number) => void;
} : T) & { [K in keyof Omit<T, "each">]: FastCheckItBuilder<T[K]> };
//#endregion
export { It as n, FastCheckItBuilder as t };