---
title: "Testing an extension"
description: "Test an extension the way a member uses it, on a scratch branch of its source repo, before you merge it."
---

> Documentation Index
> Fetch the complete documentation index at: https://buildrforge.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing an extension

Forge has no test runner for extensions. Test an extension the way a member uses it: commit it to a branch of its source repo, then exercise each tool, workflow, and page on that branch against data you put there, and read back what changed. Do it before you open the change request, and again after each fix.

## Work on a scratch branch

A branch holds its own data, and the branch's tools read and write it, so a branch made for testing keeps your test data off `main`.

1. Create a branch from the branch that holds the extension.
2. Put the records, tags, and files that the tools need on it with the usual operations. Choose values that tell cases apart: two companies with different statuses, a record that references another, a field left empty.
3. Commit, so that the branch runs the version its head commit publishes, and list the commit's publications with `forge extensions list-commit-extension-publications --commit "$COMMIT"` until the extension's is `published`. A `failed` publication names its refusal, such as `ExtensionBuildFailed`. Fix it and commit again.
4. Delete the branch when you're done.

## Call each tool

`forge extensions call-extension-tool` runs a tool as you against the branch's data. Call it once for each case you care about:

- The ordinary input, an input the tool should refuse, and the edges, such as no records, many records, or a missing optional field. An input that doesn't match the tool's schema answers `ExtensionToolInputInvalid`. A tool that throws answers `ExtensionToolFailed`, whose message and location name the line.
- After each call, read what the tool changed with the usual reads on the branch. A tool that returns the right answer can still write the wrong record. When a tool commits, read the commit.
- A tool that calls a third-party service reaches the real service through the connection bound to its requirement. Bind a connection to a sandbox or test account of the service before you call tools that write there.
- You can't call a tool as someone else. To see how the policies treat a member, [simulate](https://buildrforge.com/docs/permissions/testing/) the decision, or ask a member in that group to call the tool.

## Workflows, schedules, and triggers

- Start a workflow run on the branch with `forge extensions create-branch-extension-workflow-run`, and read it with `forge extensions get-branch-extension-workflow-run` until it is `complete`, `errored`, or `waiting`. Answer a wait with `forge extensions create-branch-extension-workflow-run-signal`, and terminate a run you no longer need. Sleeps take real time, so give a workflow you test short durations through its input, or terminate it once you've seen it wait.
- Schedules and triggers run on `main` only. Before you merge, call the tool that each one runs on the branch, with the schedule's input or with an advance such as `{"branch":"main","fromCommitId":"commit_...","toCommitId":"commit_...","kind":"commit"}`. That call acts as you, with the branch you name as `ctx.branch`, and writes wherever the tool's code writes. A real run acts as the extension and [writes only a branch of its own](https://buildrforge.com/docs/extensions/tools/#where-a-background-run-writes), so a write to a branch that the code names itself, such as `"main"`, reaches that branch in your call and fails with `RunBranchRequired` in a real run. Check that the tool writes to `ctx.branch` before you call it. After the merge, run a schedule by hand with `forge extensions create-extension-schedule-run`, and read the run it answers. A trigger runs at the next advance of a branch that it follows, so read its runs with `forge extensions list-extension-trigger-runs`.

## Pages and MCP UIs

- Serve the branch's UI with `forge extensions upsert-extension-ui-address --branch`, open the address in a browser, and use the page: it reads and writes the branch's data as the member who signed in. Read the errors the page threw with `forge extensions list-extension-ui-errors`, and clear them once a fix is committed. See [Extension UI](https://buildrforge.com/docs/extensions/extension-ui/).
- Show an [MCP UI](https://buildrforge.com/docs/extensions/mcp-ui/) with the MCP server's `show_mcp_ui` and the branch, in a client that renders MCP Apps, in both light and dark themes.

## Plain code

Code that doesn't call Forge, such as parsing, mapping, or pricing, is ordinary TypeScript. Keep it in modules of its own and test it in a [local folder](https://buildrforge.com/docs/extensions/authoring-overview/#developing-in-a-local-folder) with any test runner, keeping those tests under `tests/`. Forge bundles only the files that `index.ts` imports, and leaves `tests/` out of the published package's type declarations.

Source: https://buildrforge.com/docs/extensions/testing/index.mdx
