A comprehensive API test suite for LI.FI endpoints, built with Playwright + TypeScript and Postman/Newman, with MCP server parity tests and AI-assisted scenario generation.
| Layer | Tool | Purpose |
|---|---|---|
| Playwright + TypeScript | playwright/tests/ |
Automated regression suite, CI/CD |
| Postman collections | postman/collections/ |
Manual/exploratory API validation |
| MCP parity tests | playwright/tests/mcp-parity.spec.ts |
Validates LI.FI MCP server against REST API |
| AI scenario generator | mcp/mcp-test-scenarios.ts |
Claude generates edge case test data |
| GitHub Actions | .github/workflows/ |
CI on PR + daily scheduled health monitor |
| Endpoint | Tests | Notes |
|---|---|---|
GET /tokens |
tokens.spec.ts | Cached — see caching strategy below |
GET /chains |
chains.spec.ts | Cached |
GET /tools |
tools.spec.ts | Cached |
GET /connections |
connections.spec.ts | Not cached — param-dependent |
GET /quote |
quote.spec.ts | Never cached — real-time routing |
GET /quote (Composer) |
composer.spec.ts | Composer deposit flows |
| MCP tools | mcp-parity.spec.ts | get-chains, get-quote, get-tokens parity |
The original Postman suite fetched /tokens on every test, resulting in repeated
heavy payloads (~100k tokens across 60+ chains). This suite caches static-data
endpoints for the duration of each test run:
/tokens → cached (data changes infrequently, large payload)
/chains → cached (chain list is stable)
/tools → cached (bridge/DEX list is stable)
/quote → NEVER cached (real-time routing, must be fresh)
/routes → NEVER cached (real-time routing, must be fresh)
The LiFiApiClient class in playwright/helpers/api-client.ts handles this automatically.
The caching test in tokens.spec.ts explicitly validates that the second call is <10ms.
LI.FI launched their own MCP server in March 2026 at https://mcp.li.quest/mcp.
This wraps the REST API into tools for AI agents (Claude, Cursor, Windsurf, etc).
mcp-parity.spec.ts validates that the MCP server returns data consistent with
the underlying REST API — catching any divergence between the two surfaces.
To connect LI.FI's MCP server to Claude Desktop, add to your config:
{
"mcpServers": {
"lifi": {
"type": "http",
"url": "https://mcp.li.quest/mcp"
}
}
}mcp/mcp-test-scenarios.ts uses an LLM (Claude by default) to generate diverse
edge case test scenarios across multiple endpoints — /quote, /connections,
/tokens, /chains, and /tools.
npm run scenariosOutput is saved to mcp/generated-scenarios.json. The Playwright test suite
consumes these scenarios automatically via
playwright/helpers/agentic-scenarios.ts → getAgentScenarios(endpoint):
quote.spec.ts— loads/quotescenarios (positive + negative + edge cases)connections.spec.ts— loads/connectionsscenarios
Deterministic fallback: if the JSON file is missing or the LLM call fails,
the tests skip the agentic block gracefully — the deterministic suite still runs.
To regenerate scenarios, set ANTHROPIC_API_KEY in .env and run
npm run scenarios.
Postman/Newman can run the same generated scenarios by first producing iteration
data and then running the Agentic Scenarios folder:
npm run postman:data:agentic
npm run test:postman:agenticThis keeps AI-driven tests deterministic in CI by using checked-in JSON inputs.
Each generated scenario includes:
| Field | Description |
|---|---|
endpoint |
Target API path, e.g. /quote |
params |
Query parameters passed to the endpoint |
expectedStatus |
Allowed HTTP status codes |
expectedBehaviour |
valid_route | no_route | error | schema_violation |
notes |
Why this scenario is an interesting edge case |
Screen.Recording.2026-04-07.at.21.30.26.mov
npm install
npx playwright install --with-deps chromiumCopy the environment template and fill in your keys:
cp .env.example .env| Variable | Required | Purpose |
|---|---|---|
LIFI_API_KEY |
No | Increases rate limits (200 req/2h → 200 req/min) |
ANTHROPIC_API_KEY |
Only for npm run scenarios |
Claude-assisted scenario generation |
For a fast demo flow, see docs/POSTMAN-RUNBOOK.md.
- Import
postman/collections/lifi_full_suite.postman_collection.json. - Import
postman/environments/production.postman_environment.json. - Select environment
LI.FI Production. - Run folder
Connections (/connections)in Postman Runner. - For
Agentic Scenarios, run via Runner with data filepostman/data/agentic-scenarios.postman_data.json.
# All Playwright tests
npm test
# Single suite
npm run test:tokens
npm run test:quote
npm run test:composer
npm run test:mcp
# Postman collections via Newman
npm run test:postman
npm run test:postman:quote
npm run test:postman:connections
npm run test:postman:chains
npm run test:postman:tools
# AI scenario generation
npm run scenarios
npm run postman:data:agentic
npm run test:postman:agentic
# Staging environment (placeholder URL by default)
node scripts/newman-run.js --env=staging
# Type-check without running tests
npx tsc --noEmit
# View HTML report
npm run reportGitHub Actions runs on:
- Every pull request to
main - Every push to
main - Daily at 08:00 UTC (live API health monitor)
Results are uploaded as artifacts and available in the Actions tab.
lifi-api-test-suite/
├── playwright/
│ ├── tests/
│ │ ├── tokens.spec.ts
│ │ ├── chains.spec.ts
│ │ ├── tools.spec.ts
│ │ ├── connections.spec.ts
│ │ ├── quote.spec.ts
│ │ ├── composer.spec.ts
│ │ └── mcp-parity.spec.ts
│ └── helpers/
│ ├── api-client.ts # Centralised client with caching + type definitions
│ ├── assertions.ts # Shared custom assertions
│ ├── agentic-scenarios.ts # Loader for AI-generated scenario JSON
│ └── test-data.ts # Chain IDs, token addresses, test wallets
├── postman/
│ ├── collections/
│ ├── environments/
│ └── data/
├── mcp/
│ ├── mcp-test-scenarios.ts # AI-assisted scenario generator
│ └── generated-scenarios.json
├── scripts/
│ ├── newman-run.js # Newman CLI runner
│ └── generate-postman-agentic-data.js
├── .github/workflows/
│ └── api-tests.yml
├── .vscode/
│ ├── settings.json
│ └── extensions.json
├── docs/
│ └── TEST-PLAN.md
├── AGENTS.md # Context for AI agents and reviewers
├── playwright.config.ts
├── .env.example
└── package.json