durable-execution-sdk-js-testing.localdurabletestrunner.setuptestenvironment.md
December 2, 2025 ยท View on GitHub
Home > @aws/durable-execution-sdk-js-testing > LocalDurableTestRunner > setupTestEnvironment
LocalDurableTestRunner.setupTestEnvironment() method
Sets up the test environment for local durable execution testing.
This method initializes the checkpoint server, configures fake timers for time manipulation, and prepares the environment for running durable function tests. This should be called once before running any tests, typically in a test setup hook like beforeAll.
Signature:
static setupTestEnvironment(params?: LocalDurableTestRunnerSetupParameters): Promise<void>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
params |
(Optional) Optional configuration parameters for the test environment |
Returns:
Promise<void>
Promise that resolves when the test environment setup is complete
Exceptions
Will throw an error if the checkpoint server fails to start
Remarks
- If fake timers are already installed (for example, if
jest.useFakeTimers()was called previously), this function will throw an error and setup will not succeed. - Must be paired with LocalDurableTestRunner.teardownTestEnvironment() to properly clean up resources
Example
import { LocalDurableTestRunner } from "@aws/durable-execution-sdk-js-testing";
// Basic setup
beforeAll(async () => {
await LocalDurableTestRunner.setupTestEnvironment();
});
// Setup with time skipping enabled
beforeAll(async () => {
await LocalDurableTestRunner.setupTestEnvironment({ skipTime: true });
});