Skip to main content

API Reference

Enumerations

EnumerationDescription
ExecutionStatusStatus of the execution of the property
VerbosityLevelVerbosity level

Classes

ClassDescription
ArbitraryAbstract class able to generate values on type T
PreconditionFailureError type produced whenever a precondition fails
RandomWrapper around an instance of a pure-rand's random number generator offering a simpler interface to deal with random with impure patterns
StreamWrapper around IterableIterator interface offering a set of helpers to deal with iterations in a simple way
ValueA Value<T, TShrink = T> holds an internal value of type T and its associated context

Interfaces

InterfaceDescription
ArrayConstraintsConstraints to be applied on array
AsyncCommandInterface that should be implemented in order to define an asynchronous command
BigIntConstraintsConstraints to be applied on bigInt
CommandInterface that should be implemented in order to define a synchronous command
CommandsContraintsParameters for commands
ContextValueExecution context attached to one predicate run
DateConstraintsConstraints to be applied on date
DictionaryConstraintsConstraints to be applied on dictionary
DomainConstraintsConstraints to be applied on domain
DoubleConstraintsConstraints to be applied on double
EmailAddressConstraintsConstraints to be applied on emailAddress
ExecutionTreeSummary of the execution process
FalsyContraintsConstraints to be applied on falsy
FloatConstraintsConstraints to be applied on float
IAsyncPropertyInterface for asynchronous property, see IRawProperty
IAsyncPropertyWithHooksInterface for asynchronous property defining hooks, see IAsyncProperty
ICommandInterface that should be implemented in order to define a command
IntegerConstraintsConstraints to be applied on integer
IPropertyInterface for synchronous property, see IRawProperty
IPropertyWithHooksInterface for synchronous property defining hooks, see IProperty
IRawPropertyProperty
JsonSharedConstraintsShared constraints for: - json, - jsonValue,
LetrecTypedTieStrongly typed type for the tie function passed by letrec to the builder function we pass to it. You may want also want to use its loosely typed version LetrecLooselyTypedTie.
LoremConstraintsConstraints to be applied on lorem
MapConstraintsConstraints to be applied on map
MixedCaseConstraintsConstraints to be applied on mixedCase
NatConstraintsConstraints to be applied on nat
ObjectConstraintsConstraints for anything and object
OptionConstraintsConstraints to be applied on option
ParametersCustomization of the parameters used to run the properties
RunDetailsCommonShared part between variants of RunDetails
RunDetailsFailureInterruptedRun reported as failed because it took too long and thus has been interrupted
RunDetailsFailurePropertyRun reported as failed because the property failed
RunDetailsFailureTooManySkipsRun reported as failed because too many retries have been attempted to generate valid values
RunDetailsSuccessRun reported as success
SchedulerInstance able to reschedule the ordering of promises for a given app
SchedulerConstraintsConstraints to be applied on scheduler
SchedulerReportItemDescribe a task for the report produced by the scheduler
ShuffledSubarrayConstraintsConstraints to be applied on shuffledSubarray
SparseArrayConstraintsConstraints to be applied on sparseArray
StringSharedConstraintsConstraints to be applied on arbitraries for strings
SubarrayConstraintsConstraints to be applied on subarray
UuidConstraintsConstraints to be applied on uuid
WebAuthorityConstraintsConstraints to be applied on webAuthority
WebFragmentsConstraintsConstraints to be applied on webFragments
WebPathConstraintsConstraints to be applied on webPath
WebQueryParametersConstraintsConstraints to be applied on webQueryParameters
WebSegmentConstraintsConstraints to be applied on webSegment
WebUrlConstraintsConstraints to be applied on webUrl
WeightedArbitraryConjonction of a weight and an arbitrary used by oneof in order to generate values
WithCloneMethodObject instance that should be cloned from one generation/shrink to another

Type Aliases

Type AliasDescription
AsyncPropertyHookFunctionType of legal hook function that can be used to call beforeEach or afterEach on a IAsyncPropertyWithHooks
BigIntArrayConstraintsConstraints to be applied on typed arrays for big int values
CloneValueType of the value produced by clone
DepthContextInstance of depth, can be used to alter the depth perceived by an arbitrary or to bias your own arbitraries based on the current depth
DepthIdentifierType used to strongly type instances of depth identifier while keeping internals what they contain internally
DepthSizeSuperset of Size to override the default defined for size. It can either be based on a numeric value manually selected by the user (not recommended) or rely on presets based on size (recommended).
EntityGraphArbitrariesDefines all entity types and their data fields for entityGraph.
EntityGraphContraintsConstraints to be applied on entityGraph
EntityGraphRelationsDefines all relationships between entity types for entityGraph.
EntityGraphValueType of the values generated by entityGraph.
FalsyValueTyping for values generated by falsy
Float32ArrayConstraintsConstraints to be applied on float32Array
Float64ArrayConstraintsConstraints to be applied on float64Array
GeneratorValueAn instance of GeneratorValue can be leveraged within predicates themselves to produce extra random values while preserving part of the shrinking capabilities on the produced values.
GlobalAsyncPropertyHookFunctionType of legal hook function that can be used in the global parameter asyncBeforeEach and/or asyncAfterEach
GlobalParametersType describing the global overrides
GlobalPropertyHookFunctionType of legal hook function that can be used in the global parameter beforeEach and/or afterEach
IntArrayConstraintsConstraints to be applied on typed arrays for integer values
JsonValueTypings for a Json value
LetrecLooselyTypedBuilderLoosely typed type for the builder function passed to letrec. You may want also want to use its strongly typed version LetrecTypedBuilder.
LetrecLooselyTypedTieLoosely typed type for the tie function passed by letrec to the builder function we pass to it. You may want also want to use its strongly typed version LetrecTypedTie.
LetrecTypedBuilderStrongly typed type for the builder function passed to letrec. You may want also want to use its loosely typed version LetrecLooselyTypedBuilder.
LetrecValueType of the value produced by letrec
MaybeWeightedArbitraryEither an Arbitrary<T> or a WeightedArbitrary<T>
MemoOutput type for memo
ModelRunAsyncSetupAsynchronous definition of model and real
ModelRunSetupSynchronous definition of model and real
OneOfConstraintsConstraints to be applied on oneof
OneOfValueInfer the type of the Arbitrary produced by oneof given the type of the source arbitraries
PropertyFailureRepresent failures of the property
PropertyHookFunctionType of legal hook function that can be used to call beforeEach or afterEach on a IPropertyWithHooks
RandomGeneratorMerged type supporting both pure-rand v7 and v8 random generators. Keeping compatibility with v7 avoids a breaking API change and a new major version.
RandomTypeRandom generators automatically recognized by the framework without having to pass a builder function
RecordConstraintsConstraints to be applied on record
RecordValueInfer the type of the Arbitrary produced by record given the type of the source arbitrary and constraints to be applied
RunDetailsPost-run details produced by check
SchedulerActFunction responsible to run the passed function and surround it with whatever needed. The name has been inspired from the act function coming with React.
SchedulerSequenceItemDefine an item to be passed to scheduleSequence
SetConstraintsConstraints to be applied on set
SizeThe size parameter defines how large the generated values could be.
SizeForArbitrarySuperset of Size to override the default defined for size
StringConstraintsConstraints to be applied on arbitrary string
StringMatchingConstraintsConstraints to be applied on the arbitrary stringMatching
UniqueArrayConstraintsConstraints implying known and optimized comparison function to be applied on uniqueArray
UniqueArrayConstraintsCustomCompareConstraints implying a fully custom comparison function to be applied on uniqueArray
UniqueArrayConstraintsCustomCompareSelectConstraints implying fully custom comparison function and selector to be applied on uniqueArray
UniqueArrayConstraintsRecommendedConstraints implying known and optimized comparison function to be applied on uniqueArray
UniqueArraySharedConstraintsShared constraints to be applied on uniqueArray
WithAsyncToStringMethodInterface to implement for asyncToStringMethod
WithToStringMethodInterface to implement for toStringMethod

Variables

VariableDescription
__commitHashCommit hash of the current code (eg.: process.env.COMMIT_HASH)
__typeType of module (commonjs or module)
__versionVersion of fast-check used by your project (eg.: process.env.PACKAGE_VERSION)
asyncToStringMethodUse this symbol to define a custom serializer for your instances. Serializer must be a function returning a promise of string (see WithAsyncToStringMethod).
cloneMethodGenerated instances having a method [cloneMethod] will be automatically cloned whenever necessary
toStringMethodUse this symbol to define a custom serializer for your instances. Serializer must be a function returning a string (see WithToStringMethod).

Functions

FunctionDescription
anythingFor any type of values
arrayFor arrays of values coming from arb
assertRun the property, throw in case of failure
asyncDefaultReportMessageFormat output of check using the default error reporting of assert
asyncModelRunRun asynchronous commands over a Model and the Real system
asyncPropertyInstantiate a new fast-check#IAsyncProperty
asyncStringifyConvert any value to its fast-check string representation
base64StringFor base64 strings
bigIntFor bigint
bigInt64ArrayFor BigInt64Array
bigUint64ArrayFor BigUint64Array
booleanFor boolean values - true or false
checkRun the property, do not throw contrary to assert
cloneClone the values generated by arb in order to produce fully equal values (might not be equal in terms of === or ==)
cloneIfNeededClone an instance if needed
commandsFor arrays of AsyncCommand to be executed by asyncModelRun
compareBooleanFuncFor comparison boolean functions
compareFuncFor comparison functions
configureGlobalDefine global parameters that will be used by all the runners
constantFor value
constantFromFor one ...values values - all equiprobable
contextProduce a ContextValue instance
createDepthIdentifierCreate a new and unique instance of DepthIdentifier that can be shared across multiple arbitraries if needed
dateFor date between constraints.min or new Date(-8640000000000000) (included) and constraints.max or new Date(8640000000000000) (included)
defaultReportMessageFormat output of check using the default error reporting of assert
dictionaryFor dictionaries with keys produced by keyArb and values from valueArb
domainFor domains having an extension with at least two lowercase characters
doubleFor 64-bit floating point numbers: - sign: 1 bit - significand: 52 bits - exponent: 11 bits
emailAddressFor email address
entityGraphGenerates interconnected entities with relationships based on a schema definition.
falsyFor falsy values: - '' - 0 - NaN - false - null - undefined - 0n (whenever withBigInt: true)
floatFor 32-bit floating point numbers: - sign: 1 bit - significand: 23 bits - exponent: 8 bits
float32ArrayFor Float32Array
float64ArrayFor Float64Array
funcFor pure functions
genGenerate values within the test execution itself by leveraging the strength of gen
getDepthContextForGet back the requested DepthContext
hasAsyncToStringMethodCheck if an instance implements WithAsyncToStringMethod
hasCloneMethodCheck if an instance has to be clone
hashCRC-32 based hash function
hasToStringMethodCheck if an instance implements WithToStringMethod
infiniteStreamProduce an infinite stream of values
int16ArrayFor Int16Array
int32ArrayFor Int32Array
int8ArrayFor Int8Array
integerFor integers between min (included) and max (included)
ipV4For valid IP v4
ipV4ExtendedFor valid IP v4 according to WhatWG
ipV6For valid IP v6
jsonFor any JSON strings
jsonValueFor any JSON compliant values
letrecFor mutually recursive types
limitShrinkCreate another Arbitrary with a limited (or capped) number of shrink values
loremFor lorem ipsum string of words or sentences with maximal number of words or sentences
mapFor Maps with keys produced by keyArb and values from valueArb
mapToConstantGenerate non-contiguous ranges of values by mapping integer values to constant
maxSafeIntegerFor integers between Number.MIN_SAFE_INTEGER (included) and Number.MAX_SAFE_INTEGER (included)
maxSafeNatFor positive integers between 0 (included) and Number.MAX_SAFE_INTEGER (included)
memoFor mutually recursive types
mixedCaseRandomly switch the case of characters generated by stringArb (upper/lower)
modelRunRun synchronous commands over a Model and the Real system
natFor positive integers between 0 (included) and 2147483647 (included)
noBiasBuild an arbitrary without any bias.
noShrinkBuild an arbitrary without shrinking capabilities.
objectFor any objects
oneofFor one of the values generated by ...arbs - with all ...arbs equiprobable
optionFor either nil or a value coming from arb with custom frequency
preAdd pre-condition checks inside a property execution
propertyInstantiate a new fast-check#IProperty
readConfigureGlobalRead global parameters that will be used by runners
recordFor records following the recordModel schema
resetConfigureGlobalReset global parameters
sampleGenerate an array containing all the values that would have been generated during assert or check
scheduledModelRunRun asynchronous and scheduled commands over a Model and the Real system
schedulerFor scheduler of promises
schedulerForFor custom scheduler with predefined resolution order
setFor sets of values coming from arb
shuffledSubarrayFor subarrays of originalArray
sparseArrayFor sparse arrays of values coming from arb
statisticsGather useful statistics concerning generated values
streamCreate a Stream based on g
stringFor strings of char
stringifyConvert any value to its fast-check string representation
stringMatchingFor strings matching the provided regex
subarrayFor subarrays of originalArray (keeps ordering)
tupleFor tuples produced using the provided arbs
uint16ArrayFor Uint16Array
uint32ArrayFor Uint32Array
uint8ArrayFor Uint8Array
uint8ClampedArrayFor Uint8ClampedArray
ulidFor ulid
uniqueArrayFor arrays of unique values coming from arb
uuidFor UUID from v1 to v5
webAuthorityFor web authority
webFragmentsFor fragments of an URI (web included)
webPathFor web path
webQueryParametersFor query parameters of an URI (web included)
webSegmentFor internal segment of an URI (web included)
webUrlFor web url