Skip to main content
The Typescript SDK has a companion library which makes it easy to test against a Restate container: @restatedev/restate-sdk-testcontainers. This uses Testcontainers to run a Restate Server in a Docker container and let you test your Restate handlers.

Setup

RestateTestEnvironment.start creates a Restate container and executes a user-provided closure to register services. An optional second argument allows you to specify a custom Testcontainer for Restate.

Calling services

The Restate ingress client can be used as usual (see the clients documentation)

Checking and mutating state

The stateOf method on the RestateTestEnvironment class can be used to obtain a handle on the Virtual Object / Workflow state for a particular key.

Typed state

stateOf can be provided with a type for the services state, to allow for type-safe state operations.

Testing non-determinism bugs

Forces Restate to replay the handler on every suspension point. Use this to hunt non-determinism bugs. If your handler is not replay-safe, this will surface the issue:

Disabling retries

Disabling Restate’s built-in retry policy lets you surface failures immediately instead of hanging through retry backoff. Useful when testing error paths in your handlers: