A self-contained mock API server with tat test files that demonstrate every major tat-cli feature.
This project is designed to run standalone — clone it, open it in StackBlitz, or drop it anywhere on disk. There's no build step and no dependency to install for the server itself; it uses Node's built-in node:http. The bundled package.json exists only to mark the project as ESM ("type": "module") and to provide convenient npm scripts.
All commands below run from this folder (sample-api/) — no repo root required.
# Terminal 1 — start the mock server
npm start
# (equivalent to: node server.js)
# Terminal 2 — run all tests
npm test
# (equivalent to: npx @nanotiny/tiny-api-test run tests/)Note: The server stores all data in memory. Some test files (e.g.
auth-flow.tat.yml) use hardcoded emails, so they will fail on a second run if the server is still holding state from the first run. Restart the server before re-running tests to get a clean slate.
Or call the CLI directly for finer control:
# Run a single file
npx @nanotiny/tiny-api-test run tests/auth-flow.tat.yml
# Run only smoke-tagged suites
npx @nanotiny/tiny-api-test run tests/ --tag smoke
# Run the full project management flow
npx @nanotiny/tiny-api-test run tests/project-management-flow.tat.ymlA project management API with linked entities: users, workspaces, projects, tasks, and comments. All data lives in memory — restart the server for a clean state.
| Group | Endpoints |
|---|---|
| Auth | POST /auth/register, POST /auth/login, POST /auth/refresh, POST /auth/logout, GET /auth/me |
| Workspaces | POST /workspaces, GET /workspaces, GET /workspaces/:id, POST /workspaces/:id/members, GET /workspaces/:id/members |
| Projects | POST /workspaces/:id/projects, GET /workspaces/:id/projects, GET /projects/:id, PATCH /projects/:id, DELETE /projects/:id |
| Tasks | POST /projects/:id/tasks, GET /projects/:id/tasks, GET /tasks/:id, PATCH /tasks/:id, DELETE /tasks/:id, POST /tasks/:id/assign, POST /tasks/:id/complete |
| Comments | POST /tasks/:id/comments, GET /tasks/:id/comments, DELETE /comments/:id |
| Queries | GET /tasks?status=open, ?priority=high, ?assignee=me, ?search=login, ?page=1&pageSize=10, ?sortBy=createdAt&sortDirection=desc |
| File | tat Features Demonstrated |
|---|---|
auth-flow.tat.yml |
Full auth lifecycle flow — register, login, token refresh, logout. Capture chaining, $headers assertion, response: true, error cases |
project-management-flow.tat.yml |
End-to-end project management — setup hook, workspace/project/task CRUD, comments, response: { body: true }, timeout, $duration, cross-suite capture chaining |
task-queries-flow.tat.yml |
Task query features — setup hook, filter/search/pagination/sort via query params, contains assertions |
Flow test files that need pre-authenticated access use:
setup: node scripts/get-token.jsThe
scripts/folder lives insidetests/, so the path is straightforward —tatrunssetupcommands with their working directory set to the folder containing the.tat.ymlfile.
The script calls POST /auth/register and POST /auth/login, then prints JSON to stdout:
{ "token": "...", "userId": "...", "userName": "...", "userEmail": "..." }tat merges this into the test environment so {{token}}, {{userId}}, etc. are available in all tests.
The server listens on port 3000 by default. Override with the PORT environment variable:
PORT=4000 node server.jsIf you change the port, also update tests/env.json:
{ "baseUrl": "http://localhost:4000" }The setup script reads BASE_URL from its own environment if you need to point it at a non-default port:
BASE_URL=http://localhost:4000 npx @nanotiny/tiny-api-test run tests/auth.tat.yml- Open the
sample-api/folder as a StackBlitz project (Node template). - In one terminal:
npm start - In another terminal:
npm test
No npm install is required for the server itself. StackBlitz will install @nanotiny/tiny-api-test on first npx invocation (the test script uses npx -y so it accepts the prompt automatically).