Skip to content

Latest commit

 

History

History
164 lines (95 loc) · 4.06 KB

File metadata and controls

164 lines (95 loc) · 4.06 KB

Home > @aws/durable-execution-sdk-js-testing > CloudDurableTestRunner

CloudDurableTestRunner class

A test runner for durable execution functions running in the AWS cloud. This runner invokes Lambda functions and polls for execution history to provide testing capabilities for durable operations.

Signature:

export declare class CloudDurableTestRunner<TResult = any> implements DurableTestRunner<DurableOperation, TResult>

Implements: DurableTestRunner<DurableOperation, TResult>

Example 1

const runner = new CloudDurableTestRunner({
  functionName: "my-durable-function",
});

const execution = await runner.run({ payload: { input: "test" } });
const result = execution.getResult();
const stepOperation = runner.getOperation("myStep");

Example 2

const runner = new CloudDurableTestRunner({
  functionName: "my-durable-function",
  client: new LambdaClient({ region: "us-east-1" }),
  config: { pollInterval: 500 },
});

const execution = await runner.run({ payload: { input: "test" } });
const result = execution.getResult();
const stepOperation = runner.getOperation("myStep");

Constructors

Constructor

Modifiers

Description

(constructor)({ functionName, client, config, })

Creates a new CloudDurableTestRunner instance.

Methods

Method

Modifiers

Description

getOperation(name)

Gets an operation by name, defaulting to the first occurrence (index 0).

This is a convenience method equivalent to calling getOperationByNameAndIndex(name, 0).

getOperationById(id)

Gets an operation by its unique identifier.

Each operation in a durable execution has a unique ID. This method allows you to retrieve an operation when you know its specific ID.

getOperationByIndex(index)

Gets an operation by its execution order index.

Operations are indexed in the order they were executed, starting from 0. This method is useful when you know the execution order of operations.

getOperationByNameAndIndex(name, index)

Gets an operation by name and index when multiple operations have the same name.

When a durable function executes the same named operation multiple times, this method allows you to access a specific occurrence by its index.

reset()

(BETA) Resets the test runner state, clearing all cached operations and history.

This method should be called between test runs to ensure a clean state. It clears the operation index, wait manager, and operation storage, allowing the runner to be reused for multiple test executions.

run(params)

Runs the durable function and returns the test result.

This method invokes the Lambda function, polls for execution history, and returns a comprehensive test result containing the function output and all operation details.