Interface TestArgs

Extended test context with custom properties

interface TestArgs {
    _local: boolean;
    annotate: {
        (message, type?, attachment?): Promise<TestAnnotation>;
        (message, attachment?): Promise<TestAnnotation>;
    };
    expect: ExpectStatic;
    onTestFailed: ((fn, timeout?) => void);
    onTestFinished: ((fn, timeout?) => void);
    signal: AbortSignal;
    skip: {
        (note?): never;
        (condition, note?): void;
    };
    task: Readonly<Test<object>>;
}

Hierarchy

  • TestContext
    • TestArgs

Properties

_local: boolean
annotate: {
    (message, type?, attachment?): Promise<TestAnnotation>;
    (message, attachment?): Promise<TestAnnotation>;
}

Add a test annotation that will be displayed by your reporter.

Type declaration

    • (message, type?, attachment?): Promise<TestAnnotation>
    • Parameters

      • message: string
      • Optional type: string
      • Optional attachment: TestAttachment

      Returns Promise<TestAnnotation>

    • (message, attachment?): Promise<TestAnnotation>
    • Parameters

      • message: string
      • Optional attachment: TestAttachment

      Returns Promise<TestAnnotation>

expect: ExpectStatic

expect instance bound to the current test.

This API is useful for running snapshot tests concurrently because global expect cannot track them.

onTestFailed: ((fn, timeout?) => void)

Register a callback to run when this specific test fails. Useful when tests run concurrently.

Type declaration

    • (fn, timeout?): void
    • Parameters

      • fn: OnTestFailedHandler
      • Optional timeout: number

      Returns void

onTestFinished: ((fn, timeout?) => void)

Register a callback to run when this specific test finishes. Useful when tests run concurrently.

Type declaration

    • (fn, timeout?): void
    • Parameters

      • fn: OnTestFinishedHandler
      • Optional timeout: number

      Returns void

signal: AbortSignal

An AbortSignal that will be aborted if the test times out or the test run was cancelled.

skip: {
    (note?): never;
    (condition, note?): void;
}

Mark tests as skipped. All execution after this call will be skipped. This function throws an error, so make sure you are not catching it accidentally.

Type declaration

    • (note?): never
    • Parameters

      • Optional note: string

      Returns never

    • (condition, note?): void
    • Parameters

      • condition: boolean
      • Optional note: string

      Returns void

task: Readonly<Test<object>>

Metadata of the current test