Documentation
    Preparing search index...

    Interface IProps<Parameters, Ret>

    Options for dynamic executor.

    Native boundary: The location is a native directory path resolved with path.resolve, the extension is a suffix without a dot, and simultaneous bounds in-process runs only, so no process or thread is created.

    contracts/common.md#principled-implementation The fields are what selection and execution need: the prefix, the location, the parameter factory, and optional hooks, concurrency, and extension; simultaneous and the extension have documented defaults.

    contracts/common.md#clear-and-simple-design A flat option record whose optional members are the extension points (listener, filter, wrapper).

    contracts/common.md#prohibited-implementation-shortcuts Every value is caller-supplied; the defaults are the documented ones (js, one at a time).

    contracts/common.md#meaningful-documentation Each option documents its meaning, including that the filter receives a file basename and never a function name.

    interface IProps<Parameters extends any[], Ret = any> {
        extension?: string;
        filter?: (file: string) => boolean;
        location: string;
        onComplete?: (exec: IExecution) => void;
        parameters: (name: string) => Parameters;
        prefix: string;
        simultaneous?: number;
        wrapper?: (
            name: string,
            closure: DynamicExecutor.Closure<Parameters, Ret>,
            parameters: Parameters,
        ) => Promise<any>;
    }

    Type Parameters

    • Parameters extends any[]
    • Ret = any
    Index
    extension?: string

    Extension of dynamic functions.

    js
    
    filter?: (file: string) => boolean

    Filter function whether to run or not.

    The filter function is called with the file name (basename) of each dynamic function module, not with the function name. When it returns false, the file would never be imported, so that every function defined in the file would never be executed either.

    Native boundary: The predicate receives the entry name exactly as readdir lists it, without case or separator normalization, so a comparison on a case-insensitive volume is the caller's to make.

    Type Declaration

      • (file: string): boolean
      • Parameters

        • file: string

          File name (basename) of the dynamic functions

        Returns boolean

        Whether to run or not

    contracts/common.md#principled-implementation The predicate is evaluated on the file basename before the file is imported, so a false result prevents both the import and the execution of every function in it.

    contracts/common.md#clear-and-simple-design One optional predicate over one string.

    contracts/common.md#prohibited-implementation-shortcuts Selection follows the caller's predicate, not fixed names.

    contracts/common.md#meaningful-documentation The comment states the argument and the effect of a false answer.

    location: string

    Location of the test functions.

    onComplete?: (exec: IExecution) => void

    On complete function.

    Listener of completion of a test function.

    A thrown listener error rejects the run in either mode after active module tasks settle; listeners should handle their reporting errors.

    Type Declaration

      • (exec: IExecution): void
      • Parameters

        • exec: IExecution

          Execution result of a test function

        Returns void

    contracts/common.md#principled-implementation The listener is called from the finally of each execution with the execution record, so it observes both success and failure, after the completion time is set.

    contracts/common.md#clear-and-simple-design One optional callback with one record argument.

    contracts/common.md#prohibited-implementation-shortcuts The completion hook receives the actual execution record in finally; its own exception is not swallowed and can reject either execution mode.

    contracts/common.md#meaningful-documentation The comment states that it listens to the completion of a test function.

    parameters: (name: string) => Parameters

    Get parameters of a function.

    Type Declaration

    contracts/common.md#principled-implementation The function is called with the function name at each execution and returns the argument list, so each test gets fresh parameters keyed by its name.

    contracts/common.md#clear-and-simple-design One required callback with one input.

    contracts/common.md#prohibited-implementation-shortcuts Arguments come only from the caller's function.

    contracts/common.md#meaningful-documentation The comment documents the parameter and the return value.

    prefix: string

    Prefix of function name.

    Every prefixed function will be executed.

    In other words, if a function name doesn't start with the prefix, then it would never be executed. Also, when a file name (basename) does not start with the prefix, the file would never be imported either, so that every function defined in the file would never be executed.

    simultaneous?: number

    Number of simultaneous requests.

    The number of requests to be executed simultaneously.

    If you configure a value greater than one, the dynamic executor will process the functions concurrently with the given capacity value.

    1
    
    wrapper?: (
        name: string,
        closure: DynamicExecutor.Closure<Parameters, Ret>,
        parameters: Parameters,
    ) => Promise<any>

    Wrapper of test function.

    If you specify this wrapper property, every dynamic functions loaded and called by this DynamicExecutor would be wrapped by the wrapper function.

    Type Declaration

    contracts/common.md#principled-implementation When present, the wrapper is called instead of the function directly with the name, the function, and the parameters, so a caller can add setup, retries, or measurement around each test.

    contracts/common.md#clear-and-simple-design One optional callback that replaces the direct call.

    contracts/common.md#prohibited-implementation-shortcuts The executor calls the wrapper for every function it runs, without a test-specific bypass.

    contracts/common.md#meaningful-documentation The comment documents each parameter and the return value.