Repository navigation
v1.0.22 — Unit tests on tools, prompts and resources
Tools, prompts and resources can now carry saved unit tests, and npx @xano/sdk test run-all runs them with the rest. Every request the SDK makes now carries its xanosdk User-Agent, not only the CLI's, and a local Xano Engine now gets your telemetry settings.
npm install @xano/sdk@1.0.22Tools, prompts and resources carry unit tests
tool(), prompt() and resource() take tests the same way query(), defineFunction() and middleware() do: named inputs, expect.* assertions, and a statement mock keyed by test name.
tool({
name: "score",
input: { score: input.int() },
stack: [s.set_var("total", c.expression("$input.score + 1"), { mock: { mocked: c.int(100) } })],
response: ref("total"),
tests: [
{ name: "adds one", input: { score: c.int(1) }, expect: [expect.to_equal(resp(), c.int(2))] },
{ name: "mocked", input: { score: c.int(1) }, expect: [expect.to_equal(resp(), c.int(100))] },
],
});A pull brings them back, along with their mocks, so a deploy from a pulled tree no longer wipes tests written in the editor. test list, test run-all and deploy --test run them with the rest, named tool:<name>/<test> (and prompt: and resource:). test.live-datasource and test.unknown-input warn on these kinds as they do on the others. A backend whose engine predates tests on these kinds lists none of them, so the suite passes without running them.
Every SDK request sends the xanosdk User-Agent
1.0.21 added the header only to the CLI's own fetch calls. Now the MCP bridge (xanosdk local mcp --stdio) and a library run() from @xano/sdk/node send it too. The format is unchanged.
The local Xano Engine honors your telemetry choice
Passed through. DO_NOT_TRACK, CI, XANO_TELEMETRY, XANO_TELEMETRY_URL and XANO_TELEMETRY_ANONYMOUS_ID now reach an engine that deploy starts. They used to be dropped from its environment.
Restarted when it changes. A deploy that would reuse a running engine started with a different telemetry choice now restarts it, so an opt-out takes effect on the next deploy. An engine that could not report either way is still reused.