Prerequisites: Docker, to run the Restate Server in a container.
Fixture models
A fixture model returns fixed responses based on the request. Wrap it withjournaledModel, so its responses are journaled like real model calls:
messages and the available tools, and, when they apply, the instructions, maxOutputTokens, the step number, and the outputSchema for typed output. A request without a step asks for a summary, for example of a stopped run, and its name identifies the summary, such as Summarize stopped run. For typed output, return {type: "final", text: "", output}.
This fixture returns an answer only after it receives a successful lookupTicket result with valid ticket data. A missing tool or failed lookup fails the test.
Integration tests
Replace the model provider with the fixture, start the services in a Restate container, and call them through the Restate client:vi.mockreplacesaiModelwith the fixture, so the test imports the same services that your application serves.- The
fetchTicketspy calls the original function and records each call. The assertion verifies that replay doesn’t repeat the lookup, and the second test verifies that a failed lookup cannot produce a successful answer. alwaysReplaymakes Restate replay the invocation at every suspension point, anddisableRetriesmakes Restate kill an invocation that fails with a retryable error instead of retrying it. Retry policies of anasyncTool, a model, or a service still apply. See Testing.
invalid_response note instead. A fixture that returns the same call IDs in every turn therefore runs no tools after the first turn of a conversation. Use a new object key per test, or return unique call IDs per turn.
Assert on observable effects: a tool that must run once runs once, an approval blocks the run until it’s resolved, and the losing run of a race is cleaned up.
The Restate Harness integration tests test the tutorial lessons this way.