API Reference | fast-check | Property based testing framework
    Preparing search index...

    Type Alias EntityGraphContraints<TEntityFields>

    Constraints to be applied on entityGraph

    Since 4.5.0

    type EntityGraphContraints<TEntityFields> = {
        initialPoolConstraints?: {
            [EntityName in keyof TEntityFields]?: ArrayConstraints
        };
        noNullPrototype?: boolean;
        unicityConstraints?: {
            [EntityName in keyof TEntityFields]?: UniqueArrayConstraintsRecommended<
                TEntityFields[EntityName],
                unknown,
            >["selector"]
        };
    }

    Type Parameters

    • TEntityFields
    Index

    Properties

    initialPoolConstraints?: {
        [EntityName in keyof TEntityFields]?: ArrayConstraints
    }

    Controls the minimum number of entities generated for each entity type in the initial pool.

    The initial pool defines the baseline set of entities that are created before any relationships are established. Other entities may be created later to satisfy relationship requirements.

    // Ensure at least 2 employees and at most 5 teams in the initial pool
    // But possibly more than 5 teams at the end
    { initialPoolConstraints: { employee: { minLength: 2 }, team: { maxLength: 5 } } }

    When unspecified, defaults from array are used for each entity type

    Since 4.5.0

    noNullPrototype?: boolean

    Do not generate values with null prototype

    false
    

    Since 4.5.0

    unicityConstraints?: {
        [EntityName in keyof TEntityFields]?: UniqueArrayConstraintsRecommended<
            TEntityFields[EntityName],
            unknown,
        >["selector"]
    }

    Defines uniqueness criteria for entities of each type to prevent duplicate values.

    The selector function extracts a key from each entity. Entities with identical keys (compared using Object.is) are considered duplicates and only one instance will be kept.

    // Ensure employees have unique names
    { unicityConstraints: { employee: (emp) => emp.name } }
    All entities are considered unique (no deduplication is performed)
    

    Since 4.5.0