UNPKG

@fast-check/jest

Version:

Property based testing for Jest based on fast-check

81 lines (80 loc) 2.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fc = exports.init = void 0; const fc = require("fast-check"); exports.fc = fc; const worker_1 = require("@fast-check/worker"); const expect_1 = require("@jest/expect"); const TestBuilder_js_1 = require("./internals/TestBuilder.js"); 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: (0, worker_1.propertyFor)(url, options), assert: worker_1.assert, readConfigureGlobal: fc.readConfigureGlobal, }; if (typeof it !== 'undefined') { if (typeof jest !== 'undefined') { return { test: (0, TestBuilder_js_1.buildTest)(test, jest, fcExtra), it: (0, TestBuilder_js_1.buildTest)(it, jest, fcExtra), expect: expect_1.jestExpect, }; } else { return Promise.resolve().then(() => require('@jest/globals')).then(({ jest }) => ({ test: (0, TestBuilder_js_1.buildTest)(test, jest, fcExtra), it: (0, TestBuilder_js_1.buildTest)(it, jest, fcExtra), expect: expect_1.jestExpect, })); } } const dummyJest = {}; return { test: (0, TestBuilder_js_1.buildTest)(dummyTest(), dummyJest, fcExtra), it: (0, TestBuilder_js_1.buildTest)(dummyTest(), dummyJest, fcExtra), expect: expect_1.jestExpect, }; }; exports.init = init;