Tests generated API SDKs: unit tests for clients, mock-server integration tests, generated code quality gates, and regression suites.
Agentic Workflow: Read -> Reason -> Act (api-sdk-unit-tests)
You are Api Sdk Unit Tests (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-sdk-unit-tests
- Domain: Tests generated API SDKs: unit tests for clients, mock-server integration tests, generated code quality gates, and regression suites.
- sdk-unit-tests: Write unit tests for SDK client code —
npm install vitest
- integration-tests: Run SDKs against a live mock server —
npx @stoplight/prism-cli mock openapi.yaml -p 4010 &
- Check
knowledge and prerequisites: openapi-generator, node.js, python
2. Reason — think for api-sdk-unit-tests
- For
sdk-unit-tests: Write unit tests for SDK client code — decide which checks to run
- For
integration-tests: Run SDKs against a live mock server — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-sdk-unit-tests tools
- Tools:
Glob, Grep, Read, Bash, Npx (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-sdk-unit-tests:bd36217c
API SDK Engineer v2 - Testing
SDK testing and validation.
What This Skill Does
- Unit-tests client behavior with mocks
- Integration-tests against mock servers
- Gates SDK quality in CI
When to Use
- Verifying generated clients
- Catching SDK regressions
- Testing error paths
Real Commands
npm install vitest
npx vitest run tests/sdk.test.ts
npx @stoplight/prism-cli mock openapi.yaml -p 4010 &
node -e "const sdk=require('./sdk'); sdk.defaultClient.basePath='http://localhost:4010'; sdk.getUsers().then(r=>console.log(r.data.length))"
Test Pattern
import nock from 'nock';
import { UsersApi } from '../sdk';
test('lists users', async () => {
nock('https://api.example.com').get('/users').reply(200, [{ id: 1 }]);
const api = new UsersApi();
const res = await api.getUsers();
expect(res.data).toHaveLength(1);
});
Testing
- Cover success, 4xx, and 5xx paths
- Test pagination and auth headers
- Run coverage thresholds in CI
Best Practices
- Keep tests independent of live APIs
- Test through the public SDK surface
- Regenerate mocks when specs change
Capabilities
sdk-unit-tests
Write unit tests for SDK client code
Parameters:
test-file (string): Test file path
mock-target (string): URL intercepted by nock
coverage (boolean): Collect coverage
Commands:
npm install vitest
npx vitest run tests/sdk.test.ts
npx vitest run --coverage
npm install nock
node -e "const nock=require('nock'); nock('http://localhost:8080').get('/users').reply(200,[{id:1}]); fetch('https://api.example.com/users').then(r=>r.json()).then(console.log)"
Examples:
- nock intercepts HTTP for client tests
- vitest run executes the SDK test suite
- --coverage reports branch coverage
integration-tests
Run SDKs against a live mock server
Commands:
npx @stoplight/prism-cli mock openapi.yaml -p 4010 &
node -e "const sdk=require('./sdk'); sdk.defaultClient.basePath='http://localhost:4010'; sdk.getUsers().then(r=>console.log(r.data.length))"
npm test
npx vitest run
Examples:
References
1---2name: "api-sdk-unit-tests"3description: "Tests generated API SDKs: unit tests for clients, mock-server integration tests, generated code quality gates, and regression suites. Use when working with sdk unit tests, integration tests or when the user mentions sdk unit tests, integration tests."4license: "MIT"5compatibility: "Requires openapi-generator, node.js, python, typescript, swagger-codegen."6metadata:7 source: https://skillmd.com/skills/opknock/api-sdk-unit-tests8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(node:*) Bash(npm:*) Bash(npx:*)"12---1314Tests generated API SDKs: unit tests for clients, mock-server integration tests, generated code quality gates, and regression suites.1516## Agentic Workflow: Read -> Reason -> Act (api-sdk-unit-tests)1718You are **Api Sdk Unit Tests** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-sdk-unit-tests`21- Domain: Tests generated API SDKs: unit tests for clients, mock-server integration tests, generated code quality gates, and regression suites.22- **sdk-unit-tests**: Write unit tests for SDK client code — `npm install vitest`23- **integration-tests**: Run SDKs against a live mock server — `npx @stoplight/prism-cli mock openapi.yaml -p 4010 &`24- Check `knowledge` and `prerequisites: openapi-generator, node.js, python`2526### 2. Reason — think for `api-sdk-unit-tests`27- For `sdk-unit-tests`: Write unit tests for SDK client code — decide which checks to run28- For `integration-tests`: Run SDKs against a live mock server — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-sdk-unit-tests` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Npx` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-sdk-unit-tests:bd36217c`3536# API SDK Engineer v2 - Testing3738SDK testing and validation.3940## What This Skill Does41- Unit-tests client behavior with mocks42- Integration-tests against mock servers43- Gates SDK quality in CI4445## When to Use46- Verifying generated clients47- Catching SDK regressions48- Testing error paths4950## Real Commands5152```bash53npm install vitest54npx vitest run tests/sdk.test.ts55npx @stoplight/prism-cli mock openapi.yaml -p 4010 &56node -e "const sdk=require('./sdk'); sdk.defaultClient.basePath='http://localhost:4010'; sdk.getUsers().then(r=>console.log(r.data.length))"57```5859## Test Pattern6061```ts62import nock from 'nock';63import { UsersApi } from '../sdk';6465test('lists users', async () => {66 nock('https://api.example.com').get('/users').reply(200, [{ id: 1 }]);67 const api = new UsersApi();68 const res = await api.getUsers();69 expect(res.data).toHaveLength(1);70});71```7273## Testing74- Cover success, 4xx, and 5xx paths75- Test pagination and auth headers76- Run coverage thresholds in CI7778## Best Practices79- Keep tests independent of live APIs80- Test through the public SDK surface81- Regenerate mocks when specs change8283## Capabilities8485### sdk-unit-tests86Write unit tests for SDK client code8788**Parameters:**89- `test-file` (string): Test file path90- `mock-target` (string): URL intercepted by nock91- `coverage` (boolean): Collect coverage9293**Commands:**94- `npm install vitest`95- `npx vitest run tests/sdk.test.ts`96- `npx vitest run --coverage`97- `npm install nock`98- `node -e "const nock=require('nock'); nock('http://localhost:8080').get('/users').reply(200,[{id:1}]); fetch('https://api.example.com/users').then(r=>r.json()).then(console.log)"`99100**Examples:**101- nock intercepts HTTP for client tests102- vitest run executes the SDK test suite103- --coverage reports branch coverage104105### integration-tests106Run SDKs against a live mock server107108**Commands:**109- `npx @stoplight/prism-cli mock openapi.yaml -p 4010 &`110- `node -e "const sdk=require('./sdk'); sdk.defaultClient.basePath='http://localhost:4010'; sdk.getUsers().then(r=>console.log(r.data.length))"`111- `npm test`112- `npx vitest run`113114**Examples:**115- -cli --help116- -api --help117118## References119- [Vitest Docs](https://vitest.dev/guide/)120- [nock Docs](https://github.com/nock/nock)