UNPKG

@fast-check/jest

Version:

Property based testing for Jest based on fast-check

61 lines (60 loc) 1.89 kB
import { t as buildTest } from "./TestBuilder-Cff_LiBT.js"; import * as fc from "fast-check"; import { assert, propertyFor } from "@fast-check/worker"; import { jestExpect } from "@jest/expect"; //#region src/jest-fast-check-worker.ts function typedAssign(fun, others) { return Object.assign(fun, others); } function dummyTest() { return typedAssign(() => void 0, { concurrent: typedAssign(() => void 0, { each: () => () => void 0, failing: typedAssign(() => void 0, { each: () => () => void 0 }), only: typedAssign(() => void 0, { each: () => () => void 0, failing: typedAssign(() => void 0, { each: () => () => void 0 }) }), skip: typedAssign(() => void 0, { each: () => () => void 0, failing: typedAssign(() => void 0, { each: () => () => void 0 }) }) }), each: () => () => void 0, failing: typedAssign(() => void 0, { each: () => () => void 0 }), only: typedAssign(() => void 0, { each: () => () => void 0, failing: typedAssign(() => void 0, { each: () => () => void 0 }) }), skip: typedAssign(() => void 0, { each: () => () => void 0, failing: typedAssign(() => void 0, { each: () => () => void 0 }) }), todo: () => void 0 }); } const init = (url, options) => { const fcExtra = { asyncProperty: propertyFor(url, options), assert, readConfigureGlobal: fc.readConfigureGlobal }; if (typeof it !== "undefined") if (typeof jest !== "undefined") return { test: buildTest(test, jest, fcExtra), it: buildTest(it, jest, fcExtra), expect: jestExpect }; else return import("@jest/globals").then(({ jest }) => ({ test: buildTest(test, jest, fcExtra), it: buildTest(it, jest, fcExtra), expect: jestExpect })); const dummyJest = {}; return { test: buildTest(dummyTest(), dummyJest, fcExtra), it: buildTest(dummyTest(), dummyJest, fcExtra), expect: jestExpect }; }; //#endregion export { fc, init };