fast-check

  • Version 2.18.0
  • Published
  • 936 kB
  • 1 dependency
  • MIT license

Install

npm i fast-check
yarn add fast-check
pnpm add fast-check

Overview

Property based testing framework for JavaScript (like QuickCheck)

Index

Variables

Functions

Classes

Interfaces

Enums

Type Aliases

Namespaces

Variables

variable asyncToStringMethod

const asyncToStringMethod: Symbol;
  • Use this symbol to define a custom serializer for your instances. Serializer must be a function returning a promise of string (see WithAsyncToStringMethod).

    Please note that: 1. It will only be useful for asynchronous properties. 2. It has to return barely instantly.

    Remarks

    Since 2.17.0

    Modifiers

    • @public

variable clonedConstant

const clonedConstant: <T>(value: T) => Arbitrary<T>;
  • For value

    Parameter value

    The value to produce

    Remarks

    Since 1.8.0

    Modifiers

    • @public

    Deprecated

    Switch to constant instead

variable cloneMethod

const cloneMethod: Symbol;
  • Generated instances having a method [cloneMethod] will be automatically cloned whenever necessary

    This is pretty useful for statefull generated values. For instance, whenever you use a Stream you directly impact it. Implementing [cloneMethod] on the generated Stream would force the framework to clone it whenever it has to re-use it (mainly required for chrinking process)

    Remarks

    Since 1.8.0

    Modifiers

    • @public

variable dedup

const dedup: <T, N extends number>(
arb: Arbitrary<T>,
numValues: N
) => Arbitrary<CloneValue<T, N>>;
  • Remarks

    Since 1.11.0

    Modifiers

    • @public

    Deprecated

    Switch to clone instead

variable toStringMethod

const toStringMethod: Symbol;
  • Use this symbol to define a custom serializer for your instances. Serializer must be a function returning a string (see WithToStringMethod).

    Remarks

    Since 2.17.0

    Modifiers

    • @public

Functions

function anything

anything: {
(): Arbitrary<unknown>;
(constraints: ObjectConstraints): Arbitrary<unknown>;
};
  • For any type of values

    You may use sample to preview the values that will be generated

    Remarks

    Since 0.0.7

    Example 1

    null, undefined, 42, 6.5, 'Hello', {}, {k: [{}, 1, 2]}

    Modifiers

    • @public
  • For any type of values following the constraints defined by settings

    You may use sample to preview the values that will be generated

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 0.0.7

    Example 1

    null, undefined, 42, 6.5, 'Hello', {}, {k: [{}, 1, 2]}

    Example 2

    // Using custom settings
    fc.anything({
    key: fc.char(),
    values: [fc.integer(10,20), fc.constant(42)],
    maxDepth: 2
    });
    // Can build entries such as:
    // - 19
    // - [{"2":12,"k":15,"A":42}]
    // - {"4":[19,13,14,14,42,11,20,11],"6":42,"7":16,"L":10,"'":[20,11],"e":[42,20,42,14,13,17]}
    // - [42,42,42]...

    Modifiers

    • @public

function array

array: {
<T>(arb: Arbitrary<T>): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, maxLength: number): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, minLength: number, maxLength: number): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, constraints: ArrayConstraints): Arbitrary<T[]>;
};
  • For arrays of values coming from arb

    Parameter arb

    Arbitrary used to generate the values inside the array

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For arrays of values coming from arb having an upper bound size

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter maxLength

    Upper bound of the generated array size

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.array(arb, {maxLength}) - see #992. Ease the migration with our codemod script.

  • For arrays of values coming from arb having lower and upper bound size

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter minLength

    Lower bound of the generated array size

    Parameter maxLength

    Upper bound of the generated array size

    Remarks

    Since 0.0.7

    Modifiers

    • @public

    Deprecated

    Superceded by fc.array(arb, {minLength, maxLength}) - see #992. Ease the migration with our codemod script.

  • For arrays of values coming from arb having lower and upper bound size

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.4.0

    Modifiers

    • @public

function ascii

ascii: () => Arbitrary<string>;
  • For single ascii characters - char code between 0x00 (included) and 0x7f (included)

    Remarks

    Since 0.0.1

    Modifiers

    • @public

function asciiString

asciiString: {
(): Arbitrary<string>;
(maxLength: number): Arbitrary<string>;
(minLength: number, maxLength: number): Arbitrary<string>;
(constraints: StringSharedConstraints): Arbitrary<string>;
};
  • For strings of ascii

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For strings of ascii

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.asciiString({maxLength}) - see #992. Ease the migration with our codemod script.

  • For strings of ascii

    Parameter minLength

    Lower bound of the generated string length

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.asciiString({minLength, maxLength}) - see #992. Ease the migration with our codemod script.

  • For strings of ascii

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.4.0

    Modifiers

    • @public

function assert

assert: {
<Ts>(property: IAsyncProperty<Ts>, params?: Parameters<Ts>): Promise<void>;
<Ts>(property: IProperty<Ts>, params?: Parameters<Ts>): void;
<Ts>(
property: IRawProperty<Ts, boolean>,
params?: Parameters<Ts>
): void | Promise<void>;
};
  • Run the property, throw in case of failure

    It can be called directly from describe/it blocks of Mocha. It does not return anything in case of success.

    WARNING: Has to be awaited

    Parameter property

    Asynchronous property to be checked

    Parameter params

    Optional parameters to customize the execution

    Remarks

    Since 0.0.7

    Modifiers

    • @public
  • Run the property, throw in case of failure

    It can be called directly from describe/it blocks of Mocha. It does not return anything in case of success.

    Parameter property

    Synchronous property to be checked

    Parameter params

    Optional parameters to customize the execution

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • Run the property, throw in case of failure

    It can be called directly from describe/it blocks of Mocha. It does not return anything in case of success.

    WARNING: Has to be awaited if the property is asynchronous

    Parameter property

    Property to be checked

    Parameter params

    Optional parameters to customize the execution

    Remarks

    Since 0.0.7

    Modifiers

    • @public

function asyncDefaultReportMessage

asyncDefaultReportMessage: {
<Ts>(out: RunDetails<Ts> & { failed: false }): Promise<undefined>;
<Ts>(
out:
| (RunDetailsFailureProperty<Ts> & { failed: true })
| (RunDetailsFailureTooManySkips<Ts> & { failed: true })
| (RunDetailsFailureInterrupted<Ts> & { failed: true })
): Promise<string>;
<Ts>(out: RunDetails<Ts>): Promise<string>;
};
  • Format output of check using the default error reporting of assert

    Produce a string containing the formated error in case of failed run, undefined otherwise.

    Remarks

    Since 2.17.0

    Modifiers

    • @public

function asyncModelRun

asyncModelRun: <
Model extends object,
Real,
CheckAsync extends boolean,
InitialModel extends Model
>(
s: ModelRunSetup<InitialModel, Real> | ModelRunAsyncSetup<InitialModel, Real>,
cmds: Iterable<AsyncCommand<Model, Real, CheckAsync>>
) => Promise<void>;
  • Run asynchronous commands over a Model and the Real system

    Throw in case of inconsistency

    Parameter s

    Initial state provider

    Parameter cmds

    Asynchronous commands to be executed

    Remarks

    Since 1.5.0

    Modifiers

    • @public

function asyncProperty

asyncProperty: {
<T0>(
arb0: Arbitrary<T0>,
predicate: (t0: T0) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0]>;
<T0, T1>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
predicate: (t0: T0, t1: T1) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1]>;
<T0, T1, T2>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
predicate: (t0: T0, t1: T1, t2: T2) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2]>;
<T0, T1, T2, T3>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
predicate: (t0: T0, t1: T1, t2: T2, t3: T3) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3]>;
<T0, T1, T2, T3, T4>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4]>;
<T0, T1, T2, T3, T4, T5>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5]>;
<T0, T1, T2, T3, T4, T5, T6>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6]>;
<T0, T1, T2, T3, T4, T5, T6, T7>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
arb19: Arbitrary<T19>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18,
t19: T19
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
arb19: Arbitrary<T19>,
arb20: Arbitrary<T20>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18,
t19: T19,
t20: T20
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20,
T21
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
arb19: Arbitrary<T19>,
arb20: Arbitrary<T20>,
arb21: Arbitrary<T21>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18,
t19: T19,
t20: T20,
t21: T21
) => Promise<boolean | void>
): IAsyncPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20,
T21
]
>;
};
  • Instantiate a new fast-check#IAsyncProperty

    Parameter predicate

    Assess the success of the property. Would be considered falsy if it throws or if its output evaluates to false

    Remarks

    Since 0.0.7

    Modifiers

    • @public

function asyncStringify

asyncStringify: <Ts>(value: Ts) => Promise<string>;
  • Convert any value to its fast-check string representation

    This asynchronous version is also able to dig into the status of Promise

    Parameter value

    Value to be converted into a string

    Remarks

    Since 2.17.0

    Modifiers

    • @public

function base64

base64: () => Arbitrary<string>;
  • For single base64 characters - A-Z, a-z, 0-9, + or /

    Remarks

    Since 0.0.1

    Modifiers

    • @public

function base64String

base64String: {
(): Arbitrary<string>;
(maxLength: number): Arbitrary<string>;
(minLength: number, maxLength: number): Arbitrary<string>;
(constraints: StringSharedConstraints): Arbitrary<string>;
};
  • For base64 strings

    A base64 string will always have a length multiple of 4 (padded with =)

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For base64 strings

    A base64 string will always have a length multiple of 4 (padded with =)

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.base64String({maxLength}) - see #992. Ease the migration with our codemod script.

  • For base64 strings

    A base64 string will always have a length multiple of 4 (padded with =)

    Parameter minLength

    Lower bound of the generated string length

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.base64String({minLength, maxLength}) - see #992. Ease the migration with our codemod script.

  • For base64 strings

    A base64 string will always have a length multiple of 4 (padded with =)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.4.0

    Modifiers

    • @public

function bigInt

bigInt: {
(): ArbitraryWithContextualShrink<bigint>;
(min: bigint, max: bigint): ArbitraryWithContextualShrink<bigint>;
(constraints: BigIntConstraints): ArbitraryWithContextualShrink<bigint>;
};
  • For bigint

    Remarks

    Since 1.9.0

    Modifiers

    • @public
  • For bigint between min (included) and max (included)

    Parameter min

    Lower bound for the generated bigints (eg.: -5n, 0n, BigInt(Number.MIN_SAFE_INTEGER))

    Parameter max

    Upper bound for the generated bigints (eg.: -2n, 2147483647n, BigInt(Number.MAX_SAFE_INTEGER))

    Remarks

    Since 1.9.0

    Modifiers

    • @public
  • For bigint between min (included) and max (included)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.6.0

    Modifiers

    • @public

function bigIntN

bigIntN: (n: number) => ArbitraryWithContextualShrink<bigint>;
  • For signed bigint of n bits

    Generated values will be between -2^(n-1) (included) and 2^(n-1) (excluded)

    Parameter n

    Maximal number of bits of the generated bigint

    Remarks

    Since 1.9.0

    Modifiers

    • @public

function bigUint

bigUint: {
(): ArbitraryWithContextualShrink<bigint>;
(max: bigint): ArbitraryWithContextualShrink<bigint>;
(constraints: BigUintConstraints): ArbitraryWithContextualShrink<bigint>;
};
  • For positive bigint

    Remarks

    Since 1.9.0

    Modifiers

    • @public
  • For positive bigint between 0 (included) and max (included)

    Parameter max

    Upper bound for the generated bigint

    Remarks

    Since 1.9.0

    Modifiers

    • @public
  • For positive bigint between 0 (included) and max (included)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.6.0

    Modifiers

    • @public

function bigUintN

bigUintN: (n: number) => ArbitraryWithContextualShrink<bigint>;
  • For unsigned bigint of n bits

    Generated values will be between 0 (included) and 2^n (excluded)

    Parameter n

    Maximal number of bits of the generated bigint

    Remarks

    Since 1.9.0

    Modifiers

    • @public

function boolean

boolean: () => Arbitrary<boolean>;
  • For boolean values - true or false

    Remarks

    Since 0.0.6

    Modifiers

    • @public

function char

char: () => Arbitrary<string>;
  • For single printable ascii characters - char code between 0x20 (included) and 0x7e (included)

    https://www.ascii-code.com/

    Remarks

    Since 0.0.1

    Modifiers

    • @public

function char16bits

char16bits: () => Arbitrary<string>;
  • For single characters - all values in 0x0000-0xffff can be generated

    WARNING:

    Some generated characters might appear invalid regarding UCS-2 and UTF-16 encoding. Indeed values within 0xd800 and 0xdfff constitute surrogate pair characters and are illegal without their paired character.

    Remarks

    Since 0.0.11

    Modifiers

    • @public

function check

check: {
<Ts>(property: IAsyncProperty<Ts>, params?: Parameters<Ts>): Promise<
RunDetails<Ts>
>;
<Ts>(property: IProperty<Ts>, params?: Parameters<Ts>): RunDetails<Ts>;
<Ts>(property: IRawProperty<Ts, boolean>, params?: Parameters<Ts>):
| RunDetails<Ts>
| Promise<RunDetails<Ts>>;
};
  • Run the property, do not throw contrary to assert

    WARNING: Has to be awaited

    Parameter property

    Asynchronous property to be checked

    Parameter params

    Optional parameters to customize the execution

    Returns

    Test status and other useful details

    Remarks

    Since 0.0.7

    Modifiers

    • @public
  • Run the property, do not throw contrary to assert

    Parameter property

    Synchronous property to be checked

    Parameter params

    Optional parameters to customize the execution

    Returns

    Test status and other useful details

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • Run the property, do not throw contrary to assert

    WARNING: Has to be awaited if the property is asynchronous

    Parameter property

    Property to be checked

    Parameter params

    Optional parameters to customize the execution

    Returns

    Test status and other useful details

    Remarks

    Since 0.0.7

    Modifiers

    • @public

function clone

clone: <T, N extends number>(
arb: Arbitrary<T>,
numValues: N
) => Arbitrary<CloneValue<T, N>>;
  • Clone the values generated by arb in order to produce fully equal values (might not be equal in terms of === or ==)

    Parameter arb

    Source arbitrary

    Parameter numValues

    Number of values to produce

    Remarks

    Since 2.5.0

    Modifiers

    • @public

function cloneIfNeeded

cloneIfNeeded: <T>(instance: T) => T;
  • Clone an instance if needed

    Remarks

    Since 2.15.0

    Modifiers

    • @public

function commands

commands: {
<Model extends object, Real, CheckAsync extends boolean>(
commandArbs: Arbitrary<AsyncCommand<Model, Real, CheckAsync>>[],
maxCommands?: number
): Arbitrary<Iterable<AsyncCommand<Model, Real, CheckAsync>>>;
<Model extends object, Real>(
commandArbs: Arbitrary<Command<Model, Real>>[],
maxCommands?: number
): Arbitrary<Iterable<Command<Model, Real>>>;
<Model extends object, Real, CheckAsync extends boolean>(
commandArbs: Arbitrary<AsyncCommand<Model, Real, CheckAsync>>[],
constraints?: CommandsContraints
): Arbitrary<Iterable<AsyncCommand<Model, Real, CheckAsync>>>;
<Model extends object, Real>(
commandArbs: Arbitrary<Command<Model, Real>>[],
constraints?: CommandsContraints
): Arbitrary<Iterable<Command<Model, Real>>>;
};
  • For arrays of AsyncCommand to be executed by asyncModelRun

    This implementation comes with a shrinker adapted for commands. It should shrink more efficiently than array for AsyncCommand arrays.

    Parameter commandArbs

    Arbitraries responsible to build commands

    Parameter maxCommands

    Maximal number of commands to build

    Remarks

    Since 1.5.0

    Modifiers

    • @public

    Deprecated

    Superceded by fc.commands(commandArbs, {maxCommands}) - see #992. Ease the migration with our codemod script.

  • For arrays of Command to be executed by modelRun

    This implementation comes with a shrinker adapted for commands. It should shrink more efficiently than array for Command arrays.

    Parameter commandArbs

    Arbitraries responsible to build commands

    Parameter maxCommands

    Maximal number of commands to build

    Remarks

    Since 1.5.0

    Modifiers

    • @public

    Deprecated

    Superceded by fc.commands(commandArbs, {maxCommands}) - see #992. Ease the migration with our codemod script.

  • For arrays of AsyncCommand to be executed by asyncModelRun

    This implementation comes with a shrinker adapted for commands. It should shrink more efficiently than array for AsyncCommand arrays.

    Parameter commandArbs

    Arbitraries responsible to build commands

    Parameter constraints

    Contraints to be applied when generating the commands

    Remarks

    Since 1.11.0

    Modifiers

    • @public
  • For arrays of Command to be executed by modelRun

    This implementation comes with a shrinker adapted for commands. It should shrink more efficiently than array for Command arrays.

    Parameter commandArbs

    Arbitraries responsible to build commands

    Parameter constraints

    Constraints to be applied when generating the commands

    Remarks

    Since 1.11.0

    Modifiers

    • @public

function compareBooleanFunc

compareBooleanFunc: <T>() => Arbitrary<(a: T, b: T) => boolean>;
  • For comparison boolean functions

    A comparison boolean function returns: - true whenever a < b - false otherwise (ie. a = b or a > b)

    Remarks

    Since 1.6.0

    Modifiers

    • @public

function compareFunc

compareFunc: <T>() => Arbitrary<(a: T, b: T) => number>;
  • For comparison functions

    A comparison function returns: - negative value whenever a < b - positive value whenever a > b - zero whenever a and b are equivalent

    Comparison functions are transitive: a < b and b < c => a < c

    They also satisfy: a < b <=> b > a and a = b <=> b = a

    Remarks

    Since 1.6.0

    Modifiers

    • @public

function configureGlobal

configureGlobal: (parameters: GlobalParameters) => void;
  • Define global parameters that will be used by all the runners

    Parameter parameters

    Global parameters

    Remarks

    Since 1.18.0

    Example 1

    fc.configureGlobal({ numRuns: 10 });
    //...
    fc.assert(
    fc.property(
    fc.nat(), fc.nat(),
    (a, b) => a + b === b + a
    ), { seed: 42 }
    ) // equivalent to { numRuns: 10, seed: 42 }

    Modifiers

    • @public

function constant

constant: <T>(value: T) => Arbitrary<T>;
  • For value

    Parameter value

    The value to produce

    Remarks

    Since 0.0.1

    Modifiers

    • @public

function constantFrom

constantFrom: {
<T = never>(...values: T[]): Arbitrary<T>;
<TArgs extends any[] | [any]>(...values: TArgs): Arbitrary<TArgs[number]>;
};
  • For one ...values values - all equiprobable

    **WARNING**: It expects at least one value, otherwise it should throw

    Parameter values

    Constant values to be produced (all values shrink to the first one)

    Remarks

    Since 0.0.12

    Modifiers

    • @public

function context

context: () => Arbitrary<ContextValue>;
  • Produce a ContextValue instance

    Remarks

    Since 1.8.0

    Modifiers

    • @public

function convertFromNext

convertFromNext: <T>(arb: NextArbitrary<T>) => Arbitrary<T>;
  • Convert an instance of NextArbitrary to an instance of Arbitrary

    Parameter arb

    The instance to be converted

    Remarks

    Since 2.15.0

    Modifiers

    • @public

function convertFromNextWithShrunkOnce

convertFromNextWithShrunkOnce: <T>(
arb: NextArbitrary<T>,
legacyShrunkOnceContext: unknown
) => ArbitraryWithContextualShrink<T>;
  • Convert an instance of NextArbitrary to an instance of ArbitraryWithContextualShrink

    Parameter arb

    The instance to be converted

    Parameter legacyShrunkOnceContext

    Default context to be returned when shrunk once

    Remarks

    Since 2.15.0

    Modifiers

    • @public

function convertToNext

convertToNext: <T>(arb: Arbitrary<T>) => NextArbitrary<T>;
  • Convert an instance of Arbitrary to an instance of NextArbitrary

    Parameter arb

    The instance to be converted

    Remarks

    Since 2.15.0

    Modifiers

    • @public

function date

date: (constraints?: { min?: Date; max?: Date }) => Arbitrary<Date>;
  • For date between constraints.min or new Date(-8640000000000000) (included) and constraints.max or new Date(8640000000000000) (included)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 1.17.0

    Modifiers

    • @public

function defaultReportMessage

defaultReportMessage: {
<Ts>(out: RunDetails<Ts> & { failed: false }): undefined;
<Ts>(
out:
| (RunDetailsFailureProperty<Ts> & { failed: true })
| (RunDetailsFailureTooManySkips<Ts> & { failed: true })
| (RunDetailsFailureInterrupted<Ts> & { failed: true })
): string;
<Ts>(out: RunDetails<Ts>): string;
};
  • Format output of check using the default error reporting of assert

    Produce a string containing the formated error in case of failed run, undefined otherwise.

    Remarks

    Since 1.25.0

    Modifiers

    • @public

function dictionary

dictionary: <T>(
keyArb: Arbitrary<string>,
valueArb: Arbitrary<T>
) => Arbitrary<Record<string, T>>;
  • For dictionaries with keys produced by keyArb and values from valueArb

    Parameter keyArb

    Arbitrary used to generate the keys of the object

    Parameter valueArb

    Arbitrary used to generate the values of the object

    Remarks

    Since 1.0.0

    Modifiers

    • @public

function domain

domain: () => Arbitrary<string>;

function double

double: {
(): Arbitrary<number>;
(max: number): Arbitrary<number>;
(min: number, max: number): Arbitrary<number>;
(constraints: DoubleConstraints): Arbitrary<number>;
};
  • For floating point numbers between 0.0 (included) and 1.0 (excluded) - accuracy of 1 / 2**53

    Remarks

    Since 0.0.6

    Modifiers

    • @public
  • For floating point numbers between 0.0 (included) and max (excluded) - accuracy of max / 2**53

    Parameter max

    Upper bound of the generated floating point

    Remarks

    Since 1.0.0

    Modifiers

    • @public

    Deprecated

    Superceded by fc.double({max}) - see #992. Ease the migration with our codemod script.

  • For floating point numbers between min (included) and max (excluded) - accuracy of (max - min) / 2**53

    Parameter min

    Lower bound of the generated floating point

    Parameter max

    Upper bound of the generated floating point

    Remarks

    Since 1.0.0

    Modifiers

    • @public
  • For floating point numbers in range defined by constraints - accuracy of (max - min) / 2**53

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.6.0

    Modifiers

    • @public

function emailAddress

emailAddress: () => Arbitrary<string>;

function falsy

falsy: <TConstraints extends FalsyContraints>(
constraints?: TConstraints
) => Arbitrary<FalsyValue<TConstraints>>;
  • For falsy values: - '' - 0 - NaN - false - null - undefined - 0n (whenever withBigInt: true)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 1.26.0

    Modifiers

    • @public

function float

float: {
(): Arbitrary<number>;
(max: number): Arbitrary<number>;
(min: number, max: number): Arbitrary<number>;
(constraints: FloatConstraints): Arbitrary<number>;
};
  • For floating point numbers between 0.0 (included) and 1.0 (excluded) - accuracy of 1 / 2**24

    Remarks

    Since 0.0.6

    Modifiers

    • @public
  • For floating point numbers between 0.0 (included) and max (excluded) - accuracy of max / 2**24

    Parameter max

    Upper bound of the generated floating point

    Remarks

    Since 1.0.0

    Modifiers

    • @public

    Deprecated

    Superceded by fc.float({max}) - see #992. Ease the migration with our codemod script.

  • For floating point numbers between min (included) and max (excluded) - accuracy of (max - min) / 2**24

    Parameter min

    Lower bound of the generated floating point

    Parameter max

    Upper bound of the generated floating point

    Remarks

    Since 1.0.0

    Modifiers

    • @public
  • For floating point numbers in range defined by constraints - accuracy of (max - min) / 2**24

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.6.0

    Modifiers

    • @public

function float32Array

float32Array: (constraints?: Float32ArrayConstraints) => Arbitrary<Float32Array>;
  • For Float32Array

    Remarks

    Since 2.9.0

    Modifiers

    • @public

function float64Array

float64Array: (constraints?: Float64ArrayConstraints) => Arbitrary<Float64Array>;
  • For Float64Array

    Remarks

    Since 2.9.0

    Modifiers

    • @public

function frequency

frequency: {
<Ts extends WeightedArbitrary<unknown>[]>(...warbs: Ts): Arbitrary<
FrequencyValue<Ts>
>;
<Ts extends WeightedArbitrary<unknown>[]>(
constraints: FrequencyContraints,
...warbs: Ts
): Arbitrary<FrequencyValue<Ts>>;
};
  • For one of the values generated by ...warbs - the probability of selecting the ith warb is of warb[i].weight / sum(warb[j].weight)

    **WARNING**: It expects at least one (Arbitrary, weight)

    Parameter warbs

    (Arbitrary, weight)s that might be called to produce a value

    Remarks

    Since 0.0.7

    Modifiers

    • @public
  • For one of the values generated by ...warbs - the probability of selecting the ith warb is of warb[i].weight / sum(warb[j].weight)

    **WARNING**: It expects at least one (Arbitrary, weight)

    Parameter constraints

    Constraints to be applied when generating the values

    Parameter warbs

    (Arbitrary, weight)s that might be called to produce a value

    Remarks

    Since 0.0.7

    Modifiers

    • @public

function fullUnicode

fullUnicode: () => Arbitrary<string>;

function fullUnicodeString

fullUnicodeString: {
(): Arbitrary<string>;
(maxLength: number): Arbitrary<string>;
(minLength: number, maxLength: number): Arbitrary<string>;
(constraints: StringSharedConstraints): Arbitrary<string>;
};
  • For strings of fullUnicode

    Remarks

    Since 0.0.11

    Modifiers

    • @public
  • For strings of fullUnicode

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.fullUnicodeString({maxLength}) - see #992. Ease the migration with our codemod script.

  • For strings of fullUnicode

    Parameter minLength

    Lower bound of the generated string length

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.fullUnicodeString({minLength, maxLength}) - see #992. Ease the migration with our codemod script.

  • For strings of fullUnicode

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.4.0

    Modifiers

    • @public

function func

func: <TArgs extends any[], TOut>(
arb: Arbitrary<TOut>
) => Arbitrary<(...args: TArgs) => TOut>;
  • For pure functions

    Parameter arb

    Arbitrary responsible to produce the values

    Remarks

    Since 1.6.0

    Modifiers

    • @public

function genericTuple

genericTuple: <Ts extends unknown[]>(
arbs: { [K in keyof Ts]: Arbitrary<Ts[K]> }
) => Arbitrary<Ts>;
  • For tuples produced by the provided arbs

    Parameter arbs

    Ordered list of arbitraries

    Remarks

    Since 1.0.0

    Modifiers

    • @public

    Deprecated

    Switch to tuple instead

function hasAsyncToStringMethod

hasAsyncToStringMethod: <T>(
instance: T
) => instance is T & WithAsyncToStringMethod;

function hasCloneMethod

hasCloneMethod: <T>(
instance: T | WithCloneMethod<T>
) => instance is WithCloneMethod<T>;
  • Check if an instance has to be clone

    Remarks

    Since 2.15.0

    Modifiers

    • @public

function hash

hash: (repr: string) => number;
  • CRC-32 based hash function

    Used internally by fast-check in func, compareFunc or even compareBooleanFunc.

    Parameter repr

    String value to be hashed

    Remarks

    Since 2.1.0

    Modifiers

    • @public

function hasToStringMethod

hasToStringMethod: <T>(instance: T) => instance is T & WithToStringMethod;

function hexa

hexa: () => Arbitrary<string>;
  • For single hexadecimal characters - 0-9 or a-f

    Remarks

    Since 0.0.1

    Modifiers

    • @public

function hexaString

hexaString: {
(): Arbitrary<string>;
(maxLength: number): Arbitrary<string>;
(minLength: number, maxLength: number): Arbitrary<string>;
(constraints: StringSharedConstraints): Arbitrary<string>;
};
  • For strings of hexa

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For strings of hexa

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.hexaString({maxLength}) - see #992. Ease the migration with our codemod script.

  • For strings of hexa

    Parameter minLength

    Lower bound of the generated string length

    Parameter maxLength

    Upper bound of the generated string length

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.hexaString({minLength, maxLength}) - see #992. Ease the migration with our codemod script.

  • For strings of hexa

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.4.0

    Modifiers

    • @public

function infiniteStream

infiniteStream: <T>(arb: Arbitrary<T>) => Arbitrary<Stream<T>>;
  • Produce an infinite stream of values

    WARNING: Requires Object.assign

    Parameter arb

    Arbitrary used to generate the values

    Remarks

    Since 1.8.0

    Modifiers

    • @public

function int16Array

int16Array: (constraints?: IntArrayConstraints) => Arbitrary<Int16Array>;
  • For Int16Array

    Remarks

    Since 2.9.0

    Modifiers

    • @public

function int32Array

int32Array: (constraints?: IntArrayConstraints) => Arbitrary<Int32Array>;
  • For Int32Array

    Remarks

    Since 2.9.0

    Modifiers

    • @public

function int8Array

int8Array: (constraints?: IntArrayConstraints) => Arbitrary<Int8Array>;
  • For Int8Array

    Remarks

    Since 2.9.0

    Modifiers

    • @public

function integer

integer: {
(): ArbitraryWithContextualShrink<number>;
(max: number): ArbitraryWithContextualShrink<number>;
(min: number, max: number): ArbitraryWithContextualShrink<number>;
(constraints: IntegerConstraints): ArbitraryWithContextualShrink<number>;
};
  • For integers between -2147483648 (included) and 2147483647 (included)

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For integers between -2147483648 (included) and max (included)

    Parameter max

    Upper bound for the generated integers (eg.: 2147483647, Number.MAX_SAFE_INTEGER)

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.integer({max}) - see #992. Ease the migration with our codemod script.

  • For integers between min (included) and max (included)

    Parameter min

    Lower bound for the generated integers (eg.: 0, Number.MIN_SAFE_INTEGER)

    Parameter max

    Upper bound for the generated integers (eg.: 2147483647, Number.MAX_SAFE_INTEGER)

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For integers between min (included) and max (included)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.6.0

    Modifiers

    • @public

function ipV4

ipV4: () => Arbitrary<string>;
  • For valid IP v4

    Following RFC 3986

    Remarks

    Since 1.14.0

    Modifiers

    • @public

function ipV4Extended

ipV4Extended: () => Arbitrary<string>;
  • For valid IP v4 according to WhatWG

    Following WhatWG, the specification for web-browsers

    There is no equivalent for IP v6 according to the IP v6 parser

    Remarks

    Since 1.17.0

    Modifiers

    • @public

function ipV6

ipV6: () => Arbitrary<string>;
  • For valid IP v6

    Following RFC 3986

    Remarks

    Since 1.14.0

    Modifiers

    • @public

function json

json: {
(): Arbitrary<string>;
(maxDepth: number): Arbitrary<string>;
(constraints: JsonSharedConstraints): Arbitrary<unknown>;
};
  • For any JSON strings

    Keys and string values rely on string

    Remarks

    Since 0.0.7

    Modifiers

    • @public
  • For any JSON strings with a maximal depth

    Keys and string values rely on string

    Parameter maxDepth

    Maximal depth of the generated objects

    Remarks

    Since 0.0.7

    Modifiers

    • @public

    Deprecated

    Superceded by fc.json({maxDepth}) - see #992. Ease the migration with our codemod script.

  • For any JSON strings

    Keys and string values rely on string

    Parameter constraints

    Constraints to be applied onto the generated instance

    Remarks

    Since 2.5.0

    Modifiers

    • @public

function jsonObject

jsonObject: {
(): Arbitrary<unknown>;
(maxDepth: number): Arbitrary<unknown>;
(constraints: JsonSharedConstraints): Arbitrary<unknown>;
};
  • For any JSON compliant values

    Keys and string values rely on string

    As JSON.parse preserves -0, jsonObject can also have -0 as a value. jsonObject must be seen as: any value that could have been built by doing a JSON.parse on a given string.

    Remarks

    Since 1.2.3

    Modifiers

    • @public
  • For any JSON compliant values with a maximal depth

    Keys and string values rely on string

    As JSON.parse preserves -0, jsonObject can also have -0 as a value. jsonObject must be seen as: any value that could have been built by doing a JSON.parse on a given string.

    Parameter maxDepth

    Maximal depth of the generated values

    Remarks

    Since 1.2.3

    Modifiers

    • @public

    Deprecated

    Superceded by fc.jsonObject({maxDepth}) - see #992. Ease the migration with our codemod script.

  • For any JSON compliant values

    Keys and string values rely on string

    As JSON.parse preserves -0, jsonObject can also have -0 as a value. jsonObject must be seen as: any value that could have been built by doing a JSON.parse on a given string.

    Parameter constraints

    Constraints to be applied onto the generated instance

    Remarks

    Since 2.5.0

    Modifiers

    • @public

function letrec

letrec: <T>(
builder: (
tie: (key: string) => Arbitrary<unknown>
) => { [K in keyof T]: Arbitrary<T[K]> }
) => { [K in keyof T]: Arbitrary<T[K]> };
  • For mutually recursive types

    Parameter builder

    Arbitraries builder based on themselves (through tie)

    Remarks

    Since 1.16.0

    Example 1

    const { tree } = fc.letrec(tie => ({
    tree: fc.oneof({depthFactor: 0.5}, tie('leaf'), tie('node')),
    node: fc.tuple(tie('tree'), tie('tree')),
    leaf: fc.nat()
    }));
    // tree is 50% of node, 50% of leaf
    // the ratio goes in favor of leaves as we go deeper in the tree (thanks to depthFactor)

    Modifiers

    • @public

function lorem

lorem: {
(): Arbitrary<string>;
(maxWordsCount: number): Arbitrary<string>;
(maxWordsCount: number, sentencesMode: boolean): Arbitrary<string>;
(constraints: LoremConstraints): Arbitrary<string>;
};
  • For lorem ipsum strings of words

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For lorem ipsum string of words with maximal number of words

    Parameter maxWordsCount

    Upper bound of the number of words allowed

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.lorem({maxCount}) - see #992. Ease the migration with our codemod script.

  • For lorem ipsum string of words or sentences with maximal number of words or sentences

    Parameter maxWordsCount

    Upper bound of the number of words/sentences allowed

    Parameter sentencesMode

    If enabled, multiple sentences might be generated

    Remarks

    Since 0.0.1

    Modifiers

    • @public

    Deprecated

    Superceded by fc.lorem({maxCount, mode}) - see #992. Ease the migration with our codemod script.

  • For lorem ipsum string of words or sentences with maximal number of words or sentences

    Parameter constraints

    Constraints to be applied onto the generated value

    Remarks

    Since 2.5.0

    Modifiers

    • @public

function mapToConstant

mapToConstant: <T>(
...entries: { num: number; build: (idInGroup: number) => T }[]
) => Arbitrary<T>;
  • Generate non-contiguous ranges of values by mapping integer values to constant

    Parameter options

    Builders to be called to generate the values

    Remarks

    Since 1.14.0

    Example 1

    // generate alphanumeric values (a-z0-9)
    mapToConstant(
    { num: 26, build: v => String.fromCharCode(v + 0x61) },
    { num: 10, build: v => String.fromCharCode(v + 0x30) },
    )

    Modifiers

    • @public

function maxSafeInteger

maxSafeInteger: () => ArbitraryWithContextualShrink<number>;
  • For integers between Number.MIN_SAFE_INTEGER (included) and Number.MAX_SAFE_INTEGER (included)

    Remarks

    Since 1.11.0

    Modifiers

    • @public

function maxSafeNat

maxSafeNat: () => ArbitraryWithContextualShrink<number>;
  • For positive integers between 0 (included) and Number.MAX_SAFE_INTEGER (included)

    Remarks

    Since 1.11.0

    Modifiers

    • @public

function memo

memo: <T>(builder: (maxDepth: number) => Arbitrary<T>) => Memo<T>;
  • For mutually recursive types

    Parameter builder

    Arbitrary builder taken the maximal depth allowed as input (parameter n)

    Remarks

    Since 1.16.0

    Example 1

    // tree is 1 / 3 of node, 2 / 3 of leaf
    const tree: fc.Memo<Tree> = fc.memo(n => fc.oneof(node(n), leaf(), leaf()));
    const node: fc.Memo<Tree> = fc.memo(n => {
    if (n <= 1) return fc.record({ left: leaf(), right: leaf() });
    return fc.record({ left: tree(), right: tree() }); // tree() is equivalent to tree(n-1)
    });
    const leaf = fc.nat;

    Modifiers

    • @public

function mixedCase

mixedCase: (
stringArb: Arbitrary<string>,
constraints?: MixedCaseConstraints
) => Arbitrary<string>;
  • Randomly switch the case of characters generated by stringArb (upper/lower)

    WARNING: Require bigint support. Under-the-hood the arbitrary relies on bigint to compute the flags that should be toggled or not.

    Parameter stringArb

    Arbitrary able to build string values

    Parameter constraints

    Constraints to be applied when computing upper/lower case version

    Remarks

    Since 1.17.0

    Modifiers

    • @public

function modelRun

modelRun: <Model extends object, Real, InitialModel extends Model>(
s: ModelRunSetup<InitialModel, Real>,
cmds: Iterable<Command<Model, Real>>
) => void;
  • Run synchronous commands over a Model and the Real system

    Throw in case of inconsistency

    Parameter s

    Initial state provider

    Parameter cmds

    Synchronous commands to be executed

    Remarks

    Since 1.5.0

    Modifiers

    • @public

function nat

nat: {
(): ArbitraryWithContextualShrink<number>;
(max: number): ArbitraryWithContextualShrink<number>;
(constraints: NatConstraints): ArbitraryWithContextualShrink<number>;
};
  • For positive integers between 0 (included) and 2147483647 (included)

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For positive integers between 0 (included) and max (included)

    Parameter max

    Upper bound for the generated integers

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For positive integers between 0 (included) and max (included)

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 2.6.0

    Modifiers

    • @public

function object

object: {
(): Arbitrary<Record<string, unknown>>;
(constraints: ObjectConstraints): Arbitrary<Record<string, unknown>>;
};
  • For any objects

    You may use sample to preview the values that will be generated

    Remarks

    Since 0.0.7

    Example 1

    {}, {k: [{}, 1, 2]}

    Modifiers

    • @public
  • For any objects following the constraints defined by settings

    You may use sample to preview the values that will be generated

    Parameter constraints

    Constraints to apply when building instances

    Remarks

    Since 0.0.7

    Example 1

    {}, {k: [{}, 1, 2]}

    Modifiers

    • @public

function oneof

oneof: {
<Ts extends Arbitrary<unknown>[]>(...arbs: Ts): Arbitrary<OneOfValue<Ts>>;
<Ts extends Arbitrary<unknown>[]>(
constraints: OneOfConstraints,
...arbs: Ts
): Arbitrary<OneOfValue<Ts>>;
};
  • For one of the values generated by ...arbs - with all ...arbs equiprobable

    **WARNING**: It expects at least one arbitrary

    Parameter arbs

    Arbitraries that might be called to produce a value

    Remarks

    Since 0.0.1

    Modifiers

    • @public
  • For one of the values generated by ...arbs - with all ...arbs equiprobable

    **WARNING**: It expects at least one arbitrary

    Parameter constraints

    Constraints to be applied when generating the values

    Parameter arbs

    Arbitraries that might be called to produce a value

    Remarks

    Since 2.14.0

    Modifiers

    • @public

function option

option: {
<T>(arb: Arbitrary<T>): Arbitrary<T | null>;
<T>(arb: Arbitrary<T>, freq: number): Arbitrary<T>;
<T, TNil = null>(
arb: Arbitrary<T>,
constraints: OptionConstraints<TNil>
): Arbitrary<T | TNil>;
};
  • For either null or a value coming from arb

    Parameter arb

    Arbitrary that will be called to generate a non null value

    Remarks

    Since 0.0.6

    Modifiers

    • @public
  • For either null or a value coming from arb with custom frequency

    Parameter arb

    Arbitrary that will be called to generate a non null value

    Parameter freq

    The probability to build a null value is of 1 / freq

    Remarks

    Since 0.0.6

    Modifiers

    • @public

    Deprecated

    Superceded by fc.option(arb, {freq}) - see #992. Ease the migration with our codemod script.

  • For either nil or a value coming from arb with custom frequency

    Parameter arb

    Arbitrary that will be called to generate a non nil value

    Parameter constraints

    Constraints on the option

    Remarks

    Since 1.17.0

    Modifiers

    • @public

function pre

pre: (expectTruthy: boolean) => void;
  • Add pre-condition checks inside a property execution

    Parameter expectTruthy

    cancel the run whenever this value is falsy

    Remarks

    Since 1.3.0

    Modifiers

    • @public

function property

property: {
<T0>(
arb0: Arbitrary<T0>,
predicate: (t0: T0) => boolean | void
): IPropertyWithHooks<[T0]>;
<T0, T1>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
predicate: (t0: T0, t1: T1) => boolean | void
): IPropertyWithHooks<[T0, T1]>;
<T0, T1, T2>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
predicate: (t0: T0, t1: T1, t2: T2) => boolean | void
): IPropertyWithHooks<[T0, T1, T2]>;
<T0, T1, T2, T3>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
predicate: (t0: T0, t1: T1, t2: T2, t3: T3) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3]>;
<T0, T1, T2, T3, T4>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
predicate: (t0: T0, t1: T1, t2: T2, t3: T3, t4: T4) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4]>;
<T0, T1, T2, T3, T4, T5>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
predicate: (t0: T0, t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5]>;
<T0, T1, T2, T3, T4, T5, T6>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6]>;
<T0, T1, T2, T3, T4, T5, T6, T7>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12
) => boolean | void
): IPropertyWithHooks<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13
) => boolean | void
): IPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14
) => boolean | void
): IPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15
) => boolean | void
): IPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16
) => boolean | void
): IPropertyWithHooks<
[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]
>;
<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17
) => boolean | void
): IPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18
) => boolean | void
): IPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
arb19: Arbitrary<T19>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18,
t19: T19
) => boolean | void
): IPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
arb19: Arbitrary<T19>,
arb20: Arbitrary<T20>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18,
t19: T19,
t20: T20
) => boolean | void
): IPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20
]
>;
<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20,
T21
>(
arb0: Arbitrary<T0>,
arb1: Arbitrary<T1>,
arb2: Arbitrary<T2>,
arb3: Arbitrary<T3>,
arb4: Arbitrary<T4>,
arb5: Arbitrary<T5>,
arb6: Arbitrary<T6>,
arb7: Arbitrary<T7>,
arb8: Arbitrary<T8>,
arb9: Arbitrary<T9>,
arb10: Arbitrary<T10>,
arb11: Arbitrary<T11>,
arb12: Arbitrary<T12>,
arb13: Arbitrary<T13>,
arb14: Arbitrary<T14>,
arb15: Arbitrary<T15>,
arb16: Arbitrary<T16>,
arb17: Arbitrary<T17>,
arb18: Arbitrary<T18>,
arb19: Arbitrary<T19>,
arb20: Arbitrary<T20>,
arb21: Arbitrary<T21>,
predicate: (
t0: T0,
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10,
t11: T11,
t12: T12,
t13: T13,
t14: T14,
t15: T15,
t16: T16,
t17: T17,
t18: T18,
t19: T19,
t20: T20,
t21: T21
) => boolean | void
): IPropertyWithHooks<
[
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20,
T21
]
>;
};
  • Instantiate a new fast-check#IProperty

    Parameter predicate

    Assess the success of the property. Would be considered falsy if it throws or if its output evaluates to false

    Remarks

    Since 0.0.1

    Modifiers

    • @public

function readConfigureGlobal

readConfigureGlobal: () => GlobalParameters | undefined;
  • Read global parameters that will be used by runners

    Remarks

    Since 1.18.0

    Modifiers

    • @public

function record

record: {
<T>(recordModel: { [K in keyof T]: Arbitrary<T[K]> }): Arbitrary<
{ [K in keyof T]: T[K] }
>;
<T, TConstraints extends RecordConstraints<keyof T>>(
recordModel: { [K in keyof T]: Arbitrary<T[K]> },
constraints: TConstraints
): Arbitrary<RecordValue<{ [K in keyof T]: T[K] }, TConstraints>>;
};
  • For records following the recordModel schema

    Parameter recordModel

    Schema of the record

    Remarks

    Since 0.0.12

    Example 1

    record({ x: someArbitraryInt, y: someArbitraryInt }): Arbitrary<{x:number,y:number}>
    // merge two integer arbitraries to produce a {x, y} record

    Modifiers

    • @public
  • For records following the recordModel schema

    Parameter recordModel

    Schema of the record

    Parameter constraints

    Contraints on the generated record

    Remarks

    Since 0.0.12

    Example 1

    record({ x: someArbitraryInt, y: someArbitraryInt }, {withDeletedKeys: true}): Arbitrary<{x?:number,y?:number}>
    // merge two integer arbitraries to produce a {x, y}, {x}, {y} or {} record

    Modifiers

    • @public

function resetConfigureGlobal

resetConfigureGlobal: () => void;
  • Reset global parameters

    Remarks

    Since 1.18.0

    Modifiers

    • @public

function sample

sample: <Ts>(
generator: IRawProperty<Ts> | Arbitrary<Ts>,
params?: Parameters<Ts> | number
) => Ts[];
  • Generate an array containing all the values that would have been generated during assert or check

    Parameter generator

    IProperty or Arbitrary to extract the values from

    Parameter params

    Integer representing the number of values to generate or Parameters as in assert

    Remarks

    Since 0.0.6

    Example 1

    fc.sample(fc.nat(), 10); // extract 10 values from fc.nat() Arbitrary
    fc.sample(fc.nat(), {seed: 42}); // extract values from fc.nat() as if we were running fc.assert with seed=42

    Modifiers

    • @public

function scheduledModelRun

scheduledModelRun: <
Model extends object,
Real,
CheckAsync extends boolean,
InitialModel extends Model
>(
scheduler: Scheduler,
s: ModelRunSetup<InitialModel, Real> | ModelRunAsyncSetup<InitialModel, Real>,
cmds: Iterable<AsyncCommand<Model, Real, CheckAsync>>
) => Promise<void>;
  • Run asynchronous and scheduled commands over a Model and the Real system

    Throw in case of inconsistency

    Parameter scheduler

    Scheduler

    Parameter s

    Initial state provider

    Parameter cmds

    Asynchronous commands to be executed

    Remarks

    Since 1.24.0

    Modifiers

    • @public

function scheduler

scheduler: <TMetaData = unknown>(
constraints?: SchedulerConstraints
) => Arbitrary<Scheduler<TMetaData>>;
  • For scheduler of promises

    Remarks

    Since 1.20.0

    Modifiers

    • @public

function schedulerFor

schedulerFor: {
<TMetaData = unknown>(constraints?: SchedulerConstraints): (
_strs: TemplateStringsArray,
...ordering: number[]
) => Scheduler<TMetaData>;
<TMetaData = unknown>(
customOrdering: number[],
constraints?: SchedulerConstraints
): Scheduler<TMetaData>;
};
  • For custom scheduler with predefined resolution order

    Ordering is defined by using a template string like the one generated in case of failure of a scheduler

    It may be something like:

    Remarks

    Since 1.25.0

    Example 1

    fc.schedulerFor()`
    -> [task\${2}] promise pending
    -> [task\${3}] promise pending
    -> [task\${1}] promise pending
    `

    Or more generally:

    fc.schedulerFor()`
    This scheduler will resolve task ${2} first
    followed by ${3} and only then task ${1}
    `

    WARNING: Custom scheduler will neither check that all the referred promises have been scheduled nor that they resolved with the same status and value.

    WARNING: If one the promises is wrongly defined it will fail - for instance asking to resolve 5 while 5 does not exist.

    Modifiers

    • @public
  • For custom scheduler with predefined resolution order

    WARNING: Custom scheduler will not check that all the referred promises have been scheduled.

    WARNING: If one the promises is wrongly defined it will fail - for instance asking to resolve 5 while 5 does not exist.

    Parameter customOrdering

    Array defining in which order the promises will be resolved. Id of the promises start at 1. 1 means first scheduled promise, 2 second scheduled promise and so on.

    Remarks

    Since 1.25.0

    Modifiers

    • @public

function set

set: {
<T>(arb: Arbitrary<T>): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, maxLength: number): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, minLength: number, maxLength: number): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, compare: (a: T, b: T) => boolean): Arbitrary<T[]>;
<T>(
arb: Arbitrary<T>,
maxLength: number,
compare: (a: T, b: T) => boolean
): Arbitrary<T[]>;
<T>(
arb: Arbitrary<T>,
minLength: number,
maxLength: number,
compare: (a: T, b: T) => boolean
): Arbitrary<T[]>;
<T>(arb: Arbitrary<T>, constraints: SetConstraints<T>): Arbitrary<T[]>;
};
  • For arrays of unique values coming from arb

    Parameter arb

    Arbitrary used to generate the values inside the array

    Remarks

    Since 0.0.11

    Modifiers

    • @public
  • For arrays of unique values coming from arb having an upper bound size

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter maxLength

    Upper bound of the generated array size

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.set(arb, {maxLength}) - see #992. Ease the migration with our codemod script.

  • For arrays of unique values coming from arb having lower and upper bound size

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter minLength

    Lower bound of the generated array size

    Parameter maxLength

    Upper bound of the generated array size

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.set(arb, {minLength, maxLength}) - see #992. Ease the migration with our codemod script.

  • For arrays of unique values coming from arb - unicity defined by compare

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter compare

    Return true when the two values are equals

    Remarks

    Since 0.0.11

    Modifiers

    • @public

    Deprecated

    Superceded by fc.set(arb, {compare}) - see #992. Ease the migration with our codemod script.

  • For arrays of unique values coming from arb having an upper bound size - unicity defined by compare

    Parameter arb

    Arbitrary used to generate the values inside the array

    Parameter maxLength