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.
- Create a branch from the branch that holds the extension.
- 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.
- 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 ispublished. Afailedpublication names its refusal, such asExtensionBuildFailed. Fix it and commit again. - 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 answersExtensionToolFailed, 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 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 withforge extensions get-branch-extension-workflow-rununtil it iscomplete,errored, orwaiting. Answer a wait withforge 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
mainonly. 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 asctx.branch, and writes wherever the tool’s code writes. A real run acts as the extension and writes only a branch of its own, so a write to a branch that the code names itself, such as"main", reaches that branch in your call and fails withRunBranchRequiredin a real run. Check that the tool writes toctx.branchbefore you call it. After the merge, run a schedule by hand withforge 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 withforge 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 withforge extensions list-extension-ui-errors, and clear them once a fix is committed. See Extension UI. - Show an MCP UI with the MCP server’s
show_mcp_uiand 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 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.