KC's Workspace
    Preparing search index...

    Interface Test<ExtraContext>

    interface Test<ExtraContext = object> {
        annotations: TestAnnotation[];
        artifacts: TestArtifact[];
        concurrent?: boolean;
        context: TestContext & ExtraContext;
        dynamic?: boolean;
        each?: boolean;
        fails?: boolean;
        file: File;
        fullName: string;
        fullTestName: string;
        id: string;
        location?: { column: number; line: number };
        meta: TaskMeta;
        mode: RunMode;
        name: string;
        promises?: Promise<any>[];
        repeats?: number;
        result?: TaskResult;
        retry?: number;
        shuffle?: boolean;
        suite?: Suite;
        timeout: number;
        type: "test";
    }

    Type Parameters

    • ExtraContext = object

    Hierarchy (View Summary)

    Index

    Properties

    annotations: TestAnnotation[]

    An array of custom annotations.

    artifacts: TestArtifact[]

    An array of artifacts produced by the test.

    concurrent?: boolean

    Whether the task should run concurrently with other tasks.

    Test context that will be passed to the test function.

    dynamic?: boolean

    If the test was collected by parsing the file AST, and the name is not a static string, this property will be set to true.

    each?: boolean

    Whether the task was produced with .each() method.

    fails?: boolean

    Whether the task should succeed if it fails. If the task fails, it will be marked as passed.

    file: File

    File task. It's the root task of the file.

    fullName: string

    Full name including the file path, any parent suites, and this task's name.

    Uses > as the separator between levels.

    // file
    'test/task-names.test.ts'
    // suite
    'test/task-names.test.ts > meal planning'
    'test/task-names.test.ts > meal planning > grocery lists'
    // test
    'test/task-names.test.ts > meal planning > grocery lists > calculates ingredients'
    fullTestName: string

    Full name excluding the file path, including any parent suites and this task's name. undefined for file tasks.

    Uses > as the separator between levels.

    // file
    undefined
    // suite
    'meal planning'
    'meal planning > grocery lists'
    // test
    'meal planning > grocery lists > calculates ingredients'
    id: string

    Unique task identifier. Based on the file id and the position of the task. The id of the file task is based on the file path relative to root and project name. It will not change between runs.

    `1201091390`, `1201091390_0`, `1201091390_0_1`
    
    location?: { column: number; line: number }

    Location of the task in the file. This field is populated only if includeTaskLocation option is set. It is generated by calling new Error and parsing the stack trace, so the location might differ depending on the runtime.

    meta: TaskMeta

    Custom metadata for the task. JSON reporter will save this data.

    mode: RunMode

    Task mode.

    • skip: task is skipped
    • only: only this task and other tasks with only mode will run
    • todo: task is marked as a todo, alias for skip
    • run: task will run or already ran
    • queued: task will start running next. It can only exist on the File
    name: string

    Task name provided by the user. If no name was provided, it will be an empty string.

    promises?: Promise<any>[]

    Store promises (from async expects) to wait for them before finishing the test

    repeats?: number

    The amount of times the task should be repeated after the successful run. If the task fails, it will not be retried unless retry is specified.

    0
    
    result?: TaskResult

    Result of the task. Suite and file tasks will only have the result if there was an error during collection or inside afterAll/beforeAll.

    retry?: number

    The amount of times the task should be retried if it fails.

    0
    
    shuffle?: boolean

    Whether the tasks of the suite run in a random order.

    suite?: Suite

    Suite that this task is part of. File task or the global suite will have no parent.

    timeout: number

    The test timeout in milliseconds.

    type: "test"