durable-execution-sdk-js-testing.localdurabletestrunner.registerfunction.md

December 2, 2025 ยท View on GitHub

Home > @aws/durable-execution-sdk-js-testing > LocalDurableTestRunner > registerFunction

LocalDurableTestRunner.registerFunction() method

Registers a function handler that can be invoked during durable execution testing.

Signature:

registerFunction(functionName: string, handler: Handler): this;

Parameters

Parameter

Type

Description

functionName

string

The name/ARN of the function that will be used in context.invoke() calls

handler

Handler

The function handler

Returns:

this

This LocalDurableTestRunner instance for method chaining

Example

import { LocalDurableTestRunner } from "@aws/durable-execution-sdk-js-testing";
import { withDurableExecution } from "@aws/durable-execution-sdk-js";

const testRunner = new LocalDurableTestRunner({
  handlerFunction: mainHandler,
});

// Register a function
const handler = async (input, context) => {
  const response = {
    status: 200,
  };
  return response;
};

testRunner.registerFunction("get-response", handler);

// Chain multiple registrations
testRunner
  .registerFunction("workflow-a", workflowAHandler)
  .registerFunction("workflow-b", workflowBHandler);