Small tests, one file
A test case exports an array of { name, code } objects. Each code is an async function that gets g.
API Maker
The framework for AI era
Team & delivery
Test the business logic of your custom APIs and utility classes, inside API Maker.
A test case is TypeScript: a list of small tests, each an async function with node:assert. Mocks stand in for the database and system APIs, so a test checks your logic without touching real data. Run all of them, or the ones you pick, and see each result with the line that failed.
Step through it, slow it down, or open the full canvas.
Test cases live next to your code. A test case is TypeScript: an array of small tests, each with a name and an async function using node:assert. Import your utility classes and call them with g.
A test case is TypeScript: an array of small tests, each with a name and an async function using node:assert. Import your utility classes and call them with g.
Pick an API method, here g.sys.db.query, the values its arguments must have and what it returns. A matching call gets that value, no database needed.
Each test calls your real code. The query is answered by the mock, the database is not called, and every assert is checked.
Execute runs every test of the test case you are on. Run lets you check the test cases you want. Each small test shows its own result.
Someone moves the discount threshold. The failing test shows the assert message and its line in your TypeScript, before anything is deployed.
A test case exports an array of { name, code } objects. Each code is an async function that gets g.
Pick a method like g.sys.db.query, the arguments it must receive and the value it returns. Matching calls get that value.
Import your utility classes and call them as your APIs do. The test runs the same code the API runs.
Execute runs every test of the test case you are on. Run lets you tick the tests you want.
A failing test shows the assert message, the actual and expected values, and its line in your TypeScript.
Test cases go to Git with the rest of the project, so a pull request shows the tests next to the change.
Someone changes the discount threshold in a utility class. The test case fails with its message and line, before the change reaches a pull request.
import * as T from 'types';import * as assert from 'node:assert';import * as pricing from 'utils/Pricing';module.exports = [ { name: 'No discount under 1000', code: async (g: T.IAMGlobal) => { assert.strictEqual(await pricing.discountFor(g, 999), 0); }, }, { name: '10% from 1000', code: async (g: T.IAMGlobal) => { assert.strictEqual(await pricing.discountFor(g, 1000), 100); }, },];In the sandbox, like your custom APIs.
Yes, from the API testing page: send a request with any body and headers, read the response, and keep it as a saved state.
Documentation