Test Automations
Test a managed agent automation before you use it for recurring work. The test is different for each kind of automation.
| Instruction automation | Code automation | |
|---|---|---|
| How you test | Select Test or Test automation in the editor. | Write fixtures in fixtures.json, or run one fixture with type-cli automations test-code. |
| What runs | The managed agent follows the saved instructions in a private thread. | The entry stage of one subscription runs with a fixed event and fixed responses. |
| When it runs | When you select the button. | During each CLI deploy, or when you run test-code. |
Test an instruction automation
Section titled “Test an instruction automation”A private test runs the automation in a private thread in its channel. Only you can see the thread. The thread has the name of the automation, and it links back to the automation editor. Read the response, then change the instructions in the editor.
Start a private test
Section titled “Start a private test”- For a scheduled automation, open the automation from Automations in the sidebar.
- Save your changes. The test uses the saved instructions and model settings, so save first.
- Select Test.
For an event automation, open the event automation editor and select Test automation.
What a private test does
Section titled “What a private test does”- A private test does not wait for a real schedule, webhook, Slack event, or RSS item. Use it to examine the instructions and the behavior of the managed agent before you use live events.
- The test runs as the person who selects Test. A scheduled run uses the execution identity, model provider credentials, and model billing context of the automation creator.
- Each test makes a new preview in its private thread. This also occurs if the automation already delivered a result that day.
- A test ignores delivery checkpoints and duplicate-delivery checks.
- A test keeps the access requirements of the source.
- A test does not change external delivery, delivery checkpoints, or recorded automation data.
- A test can save authorized account choices. When new account choices are on for your workspace, another member’s private test can save a shared Team connection. That member must have access in the test Space, and the automation creator must have access in every destination Space. See Choose a connected account.
Test checklist
Section titled “Test checklist”Use this checklist when you test with a real trigger event:
- Make sure that the Space has the connections that it needs.
- Send a typical trigger event, or wait for one.
- Open the thread that the run made.
- Examine the response and the tool calls of the managed agent.
- Change the automation instructions if it is necessary.
- Make sure that the correct people get a notification.
Test a code automation with fixtures
Section titled “Test a code automation with fixtures”A fixture is a test case. It gives one subscription a fixed event and fixed responses for each call. You can run fixtures in two ways:
- At deploy.
type-cli automations deployruns every fixture infixtures.json. If one fails, the deploy fails and the active code does not change. A deploy from Type AI withcreate_taskhas no fixtures. - On saved code.
type-cli automations test-coderuns one fixture against the saved code of an automation, whether it is on or paused. Any member of its Space can run the fixture test. From Type AI,test_automation_codecan also test draft code that isn’t saved yet; the automation keeps running its saved version. The command uses a fixture rather than a real event. It does not enable the automation, but a passing test can complete a pending Enable request.
type-cli automations test-code <automation-id> --space <space> --arguments-file ./fixture.json --jsonFor test-code, the fixture has subscriptionId and payload, and can have checkpoint, matcher, environment, toolResponses, and integrationResponses. It cannot have name, expectedOutput, or expectedError. Read the result in the command output. A test counts as evidence for enabling only when the stage ran and the fixture includes toolResponses or integrationResponses. Use "toolResponses": [] when the stage makes no calls.
What a fixture runs
Section titled “What a fixture runs”A fixture runs one stage: the entry stage of its subscription. What happens next depends on the decision that the entry stage returns:
| The entry stage returns | In the fixture |
|---|---|
complete(value) | The fixture ends. expectedOutput is compared with value. |
blocked(reason, value) | The fixture ends. expectedOutput is compared with value. |
blocked(reason) | The fixture ends with no output. |
next(stage, input) | Type checks input against the destination stage and records the transition. The destination stage does not run. There is no output. |
An Err | The fixture fails, unless expectedError matches the error. |
A fixture never starts an agent stage, and it never runs the onResult stage of an agent. Later code stages also do not run. To check what the entry stage passes on, read transition in the test-code result. To test a later stage, call it locally with runAutomationDefinition (see Run a stage in a local test), or test it in a live run.
For example, this automation sends weekdays to an agent stage and finishes weekends in its entry stage:
import { agent, agentResult, automation, code, complete, next, recurringEventSchema,} from "@type-dot-com/sdk/automations";import { z } from "zod";
// What the agent stage gets, and what it must submit.const day = z.object({ day: z.string() });const incidentSummary = z.object({ summary: z.string().min(1) });
export default automation({ output: z.object({ day: z.string(), summary: z.string().nullable() }), deployment: { subscriptions: { daily: { title: "Daily incident summary", description: "Summarize incidents on weekdays", source: { kind: "recurring", schedule: { kind: "interval", everySeconds: 86400 }, }, entry: "start", }, }, }, stages: { // 1. Code: finish weekends here. Send weekdays to the agent. start: code({ input: recurringEventSchema, transitions: ["review"], run({ input }) { const date = input.scheduledAt.slice(0, 10); const weekday = new Date(input.scheduledAt).getUTCDay(); const isWeekend = weekday === 0 || weekday === 6;
if (isWeekend) { return complete({ day: date, summary: null }); }
return next("review", { day: date }); }, }),
// 2. Agent: summarize the day's incidents. review: agent({ input: day, output: incidentSummary, instructions: "Summarize the incidents that this Space discussed on the given day in two sentences.", onResult: "record", }),
// 3. Code: complete the run with the summary. record: code({ input: agentResult({ input: day, output: incidentSummary }), transitions: [], run({ input }) { return complete({ day: input.taskInput.day, summary: input.result.summary }); }, }), },});Its fixtures cover both paths of the entry stage. The weekday fixture has no expectedOutput, because the entry stage returns next():
[ { "name": "skips weekends", "subscriptionId": "daily", "payload": { "scheduledAt": "2026-10-10T09:00:00.000Z" }, "toolResponses": [], "expectedOutput": { "day": "2026-10-10", "summary": null } }, { "name": "sends weekdays to the agent", "subscriptionId": "daily", "payload": { "scheduledAt": "2026-10-12T09:00:00.000Z" }, "toolResponses": [] }]If you add expectedOutput to the weekday fixture, even null, the fixture fails with “Fixture output did not match expectedOutput”. When you run the weekday fixture with test-code, result.output in the command output shows the transition:
{ "stage": "start", "transition": { "kind": "next", "next": "review", "input": { "day": "2026-10-12" } }, "fixtureExecuted": true}Test environment variables
Section titled “Test environment variables”Fixtures never read saved Space variables or secrets. Supply fake user values in the optional environment map to exercise code that reads process.env:
{ "subscriptionId": "tick", "payload": { "scheduledAt": "2026-10-07T12:00:00.000Z" }, "environment": { "SERVICE_TOKEN": "synthetic-test-token" }, "toolResponses": []}Use synthetic values only. Fixture files are source-controlled and can appear in test diagnostics. Type removes reserved variable names from the map. Source validation also receives no saved variables; check required configuration inside the stage that runs, after the module has loaded.
Add a fixture
Section titled “Add a fixture”Put a fixtures.json file in the project root. It contains an array of fixtures:
[ { "name": "records the scheduled time", "subscriptionId": "hourly", "payload": { "scheduledAt": "2026-10-07T12:00:00.000Z" }, "toolResponses": [], "expectedOutput": { "checkedAt": "2026-10-07T12:00:00.000Z" } }]nameis unique in the file.subscriptionIdis the key of a subscription indeployment.subscriptions. The fixture runs that subscription’s entry stage.payloadis the event, in the same shape as a live event.expectedOutputis the exact value that the entry stage gives tocomplete()orblocked().
For all fields, see Project Files.
Give a response for each call
Section titled “Give a response for each call”Fixtures can answer two kinds of calls: integration tool calls and Custom API requests. Each of these calls needs a response in the fixture. Use the real request and the real response envelope. This fixture is for an entry stage that runs printf automation-ready with managed-sandbox exec_command, fails with “Workspace check failed” if the tool returns an error, and completes with the text:
{ "name": "command output uses the text envelope", "subscriptionId": "check", "payload": { "scheduledAt": "2026-10-07T00:00:00.000Z" }, "toolResponses": [ { "request": { "service": "managed-sandbox", "name": "exec_command", "arguments": { "command": "printf automation-ready" } }, "response": { "content": [{ "type": "text", "text": "automation-ready" }] } } ], "expectedOutput": { "text": "automation-ready" }}| Your code calls | Put the response in | Request fields | Response shape |
|---|---|---|---|
ctx.tools.call, ctx.read.call, ctx.write.call | toolResponses | service, name, arguments, organizationIntegrationId, rawSlug | { content, structuredContent?, isError? } |
ctx.read.request, ctx.write.request | integrationResponses | organizationIntegrationId, method, path, query, headers, body | { connection, data, headers, status, statusText, success, truncated } |
Rules:
- The request must match the call exactly, field by field. Leave out the fields that your code does not send.
- Effect keys are not part of the request. Do not put
effectKeyorautomationEffectKeyin a fixture. - Type uses each response one time. Two equal calls need two responses.
- A call with no matching response fails the fixture with “Unexpected fixture tool call” or “Unexpected fixture integration request”. No live request is sent.
- A response that your code does not use fails the fixture with “Unused fixture tool response” or “Unused fixture integration response”.
- For
ctx.read.callandctx.write.call, the response must havestructuredContent. JSON incontent[].textdoes not count. A response with"isError": truereturns an error to your code. - For
ctx.read.requestandctx.write.request, a response with"success": falsereturns an error to your code. - If your stage makes no calls, set
"toolResponses": [].
Calls that fixtures cannot answer
Section titled “Calls that fixtures cannot answer”In a fixture, Type rejects calls to other Type APIs. The run fails with “Unexpected fixture API request; only declared tool or integration calls are available”.
| Call | In a fixture |
|---|---|
ctx.tools.call, ctx.read.call, ctx.write.call | Supported. Give the response in toolResponses. |
replyInSlackThread | Supported. It writes with slack_post_message; reactions first read slack_get_thread_replies. Supply both responses in toolResponses. |
ctx.read.request, ctx.write.request | Supported. Give the response in integrationResponses. |
ctx.action, ctx.mutativeAction | Supported. Type records the steps in the test result. |
ctx.saveCheckpoint | Supported. The test result shows the value as nextCheckpoint. Type does not save it. |
next() to a code or agent stage | Supported. Type records the transition but does not run the next stage. |
ctx.write.sendMessage | Not supported. |
ctx.read.data | Not supported. |
ctx.read.search | Not supported. |
ctx.tools.find, ctx.tools.services | Not supported. |
| Sandbox tools | Supported only as recorded toolResponses. A test never starts the sandbox. |
For code that uses an unsupported call:
- Write fixtures for the paths that end before the call. For example, test a filtered event or an error for bad data.
- Test the path with the call in a live run. Use a test repository, a test channel, or a narrow filter. Then read the run with
type-cli automations history --space <space> --run <run-id> --include-activity. - To post in Slack instead of the Space, use
replyInSlackThreador a Slack tool throughctx.write.call. Fixtures can answer those calls.
Test an error
Section titled “Test an error”Use expectedError to make sure that a bad response fails the stage:
{ "name": "provider error is a failed operation", "subscriptionId": "check", "payload": { "scheduledAt": "2026-10-07T00:00:00.000Z" }, "toolResponses": [ { "request": { "service": "managed-sandbox", "name": "exec_command", "arguments": { "command": "printf automation-ready" } }, "response": { "content": [{ "type": "text", "text": "Workspace unavailable" }], "isError": true } } ], "expectedError": "Workspace check failed"}expectedErrorpasses if the error message contains the text.- If the stage succeeds, the fixture fails.
- A fixture error, such as a missing or unused response, fails the fixture even if its message contains the text.
- An event that does not match the subscription schema fails with
Invalid subscription event: .... You can test it withexpectedError. - Do not set both
expectedOutputandexpectedErrorin one fixture.
Test a filtered event
Section titled “Test a filtered event”For an event that a matcher or a resources filter skips, omit both expectedOutput and expectedError. The entry stage does not run, so there is no output. No output is not the same as null. Do not supply responses; an empty toolResponses array is fine. A filtered fixture with responses fails with “Unused fixture responses: the subscription matcher skipped this event”.
For AI questions, give the result in matcher. Type does not call the model in a fixture:
{ "matcher": { "decision": "skip" } }If your entry stage filters the event itself and returns complete(value), test it like any other output, with expectedOutput.
Test state
Section titled “Test state”Set checkpoint to the value that ctx.checkpoint.value has at the start of the stage:
{ "name": "stays quiet when nothing changed", "subscriptionId": "check", "checkpoint": "open", "payload": { "scheduledAt": "2026-10-07T00:00:00.000Z" }, "toolResponses": [] }A fixture does not save checkpoints. Each fixture starts with its own checkpoint, or with null if you omit it.
What to cover
Section titled “What to cover”Write one fixture for each different path in your entry stage:
- the normal case, with extra provider fields and
nulloptional fields, - each transition to another stage,
- a filtered event,
- a provider error or a response that does not match your schema,
- a missing or wrong required ID.
Do not write many fixtures for the same path.
Fixture limits
Section titled “Fixture limits”- 20 fixtures in each
fixtures.jsonfile. Names have 1 to 120 characters. - 128 tool responses and 128 integration responses in each fixture.
- All fixtures in a deploy share a 4-minute limit. Type runs 4 fixtures at a time.
- A
test-coderun also has a 4-minute limit.
What tests do not prove
Section titled “What tests do not prove”A test that passes does not prove that a live run will succeed.
Private tests of an instruction automation
Section titled “Private tests of an instruction automation”- A private test does not prove that real events arrive. It does not verify a webhook signature, an email address, or feed availability. Test real event delivery separately.
- A successful test by another person does not prove that the automation creator has the same credentials or permissions.
After you enable the automation, examine the next run in Run history.
Fixtures of a code automation
Section titled “Fixtures of a code automation”- Fixtures test entry stages only. They do not run later code stages, agent stages, or
onResultstages. - Fixtures do not call real APIs. They do not prove that your credentials work, or that the provider sends the response that you wrote.
- Fixtures do not start the sandbox.
- Fixtures do not call the model for AI questions in a matcher. To examine the answers of the model, send real example events.
- Fixtures do not prove that events reach Type.
After the deploy, watch the first live runs with type-cli automations history --space <space> --automation <automation-id>.