Type Alias TestCaseContext

TestCaseContext: {
    assert: TestContext["assert"];
    mock: TestContext["mock"];
    world: World;
    attach(
        data: string | Readable | Buffer<ArrayBufferLike>,
        options: AttachmentOptions,
    ): Promise<void>;
    link(url: string, title?: string): Promise<void>;
    log(text: string): Promise<void>;
    skip(): void;
    todo(): void;
}

A context object injected into every test step function as the first argument.

Type declaration

  • assert: TestContext["assert"]

    The assert object as provided by the test runner, including the normal methods from node:assert plus extras for dealing with snapshots.

  • mock: TestContext["mock"]

    The mock object as provided by the test runner.

  • world: World

    An object scoped only to this test case, that can be used to share state between test steps.

  • attach:function
    • Capture an attachment of some content that should be associated with this test step, and might be accessed later in a report.

      Parameters

      • data: string | Readable | Buffer<ArrayBufferLike>

        the content to attach, as a stream, buffer or just a plain string

      • options: AttachmentOptions

        declare more information about this attachment

      Returns Promise<void>

  • link:function
    • Capture a URL attachment.

      Parameters

      • url: string

        the URL to be captured

      • Optionaltitle: string

        the text title that should accompany the URL

      Returns Promise<void>

      A shorthand for TestCaseContext.attach with a special media type.

  • log:function
    • Capture a "log" attachment.

      Parameters

      • text: string

        the text to be logged

      Returns Promise<void>

      A shorthand for TestCaseContext.attach with a special media type.

  • skip:function
    • Mark this test step as skipped. This will cause all subsequent steps to be skipped, except After hooks.

      Returns void

      Results in a Cucumber status of "skipped" for the scenario.

  • todo:function
    • Mark this test step as pending. This will cause all subsequent steps to be skipped, except After hooks.

      Returns void

      Results in a Cucumber status of "pending" for the scenario.