testing-api-overrides — community testing-api-overrides, toolhive-studio, community, ide skills, Claude Code, Cursor, Windsurf

v1.0.0
GitHub

About this Skill

Ideal for API-focused agents like Claude Code and AutoGPT needing advanced API testing and validation capabilities. ToolHive is an application that allows you to install, manage and run MCP servers and connect them to AI agents

stacklok stacklok
[0]
[0]
Updated: 3/5/2026

Agent Capability Analysis

The testing-api-overrides skill by stacklok is an open-source community AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance.

Ideal Agent Persona

Ideal for API-focused agents like Claude Code and AutoGPT needing advanced API testing and validation capabilities.

Core Value

Empowers agents to verify user-facing behavior by setting up conditional API mocks that respond based on request parameters, utilizing protocols and libraries for robust testing, including conditional overrides for detailed API parameter validation.

Capabilities Granted for testing-api-overrides

Testing API overrides for user-facing behavior
Validating API parameters with conditional mocks
Debugging API integrations with ToolHive

! Prerequisites & Limits

  • Requires ToolHive application for MCP server management
  • Conditional mocks must be set up based on specific request parameters
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

testing-api-overrides

Install testing-api-overrides, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

Testing API Overrides

Test that your code sends correct API parameters by using conditional overrides that respond differently based on the request. This approach tests actual user-facing behavior rather than inspecting internal request details.

Philosophy

Good tests verify what users see, not implementation details.

Instead of:

  1. ❌ Recording the request and checking query params
  2. ❌ Asserting on internal function calls

Do this:

  1. ✅ Set up conditional mocks that respond based on params
  2. ✅ Verify the component renders the expected data

If the code sends wrong parameters, the mock returns wrong data, the UI shows wrong content, and the test fails. This catches real bugs.

When to Use Conditional Overrides

  • Testing list filtering (e.g., filter by group, status, search term)
  • Testing pagination parameters
  • Testing sort order
  • Any read operation where request parameters affect what data is returned

Note: For mutations (create/update/delete), use recordRequests() instead. See the testing-api-assertions skill.

conditionalOverride()

Returns different data based on request properties:

typescript
1import { mockedGetApiV1BetaWorkloads } from '@mocks/fixtures/workloads/get' 2 3mockedGetApiV1BetaWorkloads.conditionalOverride( 4 // Predicate: when should this override apply? 5 ({ query }) => query.group === 'archive', 6 // Transform: what data to return? 7 (data) => ({ 8 ...data, 9 workloads: [], // Archive group is empty 10 }) 11)

Predicate Function

The predicate receives parsed request info with easy access to query params, path params, body, and headers:

typescript
1;({ query, path, body, headers }) => { 2 // Query parameters (pre-parsed) 3 query.group // '?group=archive' -> 'archive' 4 query.status // '?status=running' -> 'running' 5 6 // Path parameters (from route like /workloads/:name) 7 path.name // for /workloads/:name 8 9 // Request body (for POST/PUT/DELETE) 10 body?.name // parsed JSON body 11 12 // Headers 13 headers.get('Authorization') 14 15 return true // or false 16}

Transform Function

The transform receives default data and returns modified data:

typescript
1;(data) => ({ 2 ...data, // Spread defaults 3 workloads: data.workloads?.filter( 4 // Modify as needed 5 (w) => w.status === 'running' 6 ), 7})

Example: Testing Group Filter

typescript
1import { mockedGetApiV1BetaWorkloads } from '@mocks/fixtures/workloads/get' 2 3it('shows only workloads from the selected group', async () => { 4 // Default mock returns workloads from multiple groups 5 // Add conditional override for 'production' group 6 mockedGetApiV1BetaWorkloads.conditionalOverride( 7 ({ query }) => query.group === 'production', 8 (data) => ({ 9 ...data, 10 workloads: [ 11 { name: 'prod-server-1', group: 'production', status: 'running' }, 12 { name: 'prod-server-2', group: 'production', status: 'running' }, 13 ], 14 }) 15 ) 16 17 render(<WorkloadsList group="production" />) 18 19 // If component sends ?group=production, it gets the filtered data 20 // If component forgets the param, it gets default data with mixed groups 21 await waitFor(() => { 22 expect(screen.getByText('prod-server-1')).toBeVisible() 23 expect(screen.getByText('prod-server-2')).toBeVisible() 24 }) 25 26 // These would appear if the filter param wasn't sent correctly 27 expect(screen.queryByText('dev-server')).not.toBeInTheDocument() 28})

Example: Testing Empty State

typescript
1it('shows empty message when group has no workloads', async () => { 2 mockedGetApiV1BetaWorkloads.conditionalOverride( 3 ({ query }) => query.group === 'empty-group', 4 () => ({ workloads: [] }) 5 ) 6 7 render(<WorkloadsList group="empty-group" />) 8 9 await waitFor(() => { 10 expect(screen.getByText(/no workloads found/i)).toBeVisible() 11 }) 12})

Multiple Conditional Overrides

Chain multiple overrides for different conditions:

typescript
1mockedGetApiV1BetaWorkloads 2 .conditionalOverride( 3 ({ query }) => query.group === 'production', 4 () => ({ workloads: productionWorkloads }) 5 ) 6 .conditionalOverride( 7 ({ query }) => query.group === 'staging', 8 () => ({ workloads: stagingWorkloads }) 9 )

Later overrides wrap earlier ones. If no predicate matches, the default fixture data is returned.

Simple Overrides (No Condition)

For test-scoped data changes without conditions, use .override():

typescript
1// Override for entire test - no condition 2mockedGetApiV1BetaGroups.override(() => ({ 3 groups: [{ name: 'only-group', registered_clients: [] }], 4})) 5 6// Modify default data 7mockedGetApiV1BetaGroups.override((data) => ({ 8 ...data, 9 groups: data.groups?.slice(0, 1), 10}))

Error Responses

Use .overrideHandler() for full control over the response:

typescript
1import { HttpResponse } from 'msw' 2 3// Return error 4mockedGetApiV1BetaGroups.overrideHandler(() => 5 HttpResponse.json({ error: 'Server error' }, { status: 500 }) 6) 7 8// Network failure 9mockedGetApiV1BetaGroups.overrideHandler(() => HttpResponse.error())

Automatic Reset

All overrides are automatically reset before each test via resetAllAutoAPIMocks() in vitest.setup.ts. No cleanup needed.

Reusable Scenarios

When the same response override is needed across many tests, define it as a scenario in the fixture instead of duplicating .override() calls.

Defining Scenarios (in fixtures)

typescript
1// In fixtures/workloads/get.ts 2export const mockedGetApiV1BetaWorkloads = AutoAPIMock<...>({ 3 workloads: [/* default data */], 4}).scenario('empty', (mock) => mock.override(() => ({ workloads: [] })))

Using Scenarios (in tests)

typescript
1mockedGetApiV1BetaWorkloads.activateScenario('empty')

Scenario names are defined in renderer/src/common/mocks/scenarioNames.ts. Use existing names when possible to keep scenarios consolidated.

  • testing-with-api-mocks - Auto-generated mocks and fixture basics
  • testing-api-assertions - Verifying mutations with recordRequests() (create/update/delete only)

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is testing-api-overrides?

Ideal for API-focused agents like Claude Code and AutoGPT needing advanced API testing and validation capabilities. ToolHive is an application that allows you to install, manage and run MCP servers and connect them to AI agents

How do I install testing-api-overrides?

Run the command: npx killer-skills add stacklok/toolhive-studio/testing-api-overrides. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for testing-api-overrides?

Key use cases include: Testing API overrides for user-facing behavior, Validating API parameters with conditional mocks, Debugging API integrations with ToolHive.

Which IDEs are compatible with testing-api-overrides?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for testing-api-overrides?

Requires ToolHive application for MCP server management. Conditional mocks must be set up based on specific request parameters.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add stacklok/toolhive-studio/testing-api-overrides. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use testing-api-overrides immediately in the current project.

Related Skills

Looking for an alternative to testing-api-overrides or another community skill for your workflow? Explore these related open-source skills.

View All

widget-generator

Logo of f
f

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

149.6k
0
AI

flags

Logo of vercel
vercel

flags is a Next.js feature management skill that enables developers to efficiently add or modify framework feature flags, streamlining React application development.

138.4k
0
Browser

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI