Mocking Stubbing
Mocking Stubbing allows you to create simplified test doubles of dependencies for isolated unit testing, speeding up development and improving test reliability.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add mocking-stubbing npx -- -y @trustedskills/mocking-stubbing
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"mocking-stubbing": {
"command": "npx",
"args": [
"-y",
"@trustedskills/mocking-stubbing"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
The mocking-stubbing skill enables AI agents to generate code for creating test doubles, such as mocks and stubs, to isolate components during unit testing. It helps developers verify logic by simulating external dependencies like databases or APIs without executing them.
When to use it
- Isolate specific functions or classes from their external dependencies to run fast, deterministic unit tests.
- Simulate complex or slow external services (e.g., payment gateways, third-party APIs) during development.
- Enforce expected behaviors in dependent objects by defining return values for specific method calls.
- Prevent side effects like database writes or network requests when testing pure business logic.
Key capabilities
- Generates mock objects that mimic the interface of real dependencies.
- Creates stubs to define fixed return values for specific function inputs.
- Produces code compatible with popular testing frameworks and languages.
- Structures test scenarios to verify interactions between components.
Example prompts
- "Write a Python unit test using
unittest.mockto mock an external API call in my service class." - "Generate a Jest stub for a database query function that returns a specific user object when called with ID 123."
- "Create a mock implementation of an email sender interface to test my notification logic without sending actual emails."
Tips & gotchas
Ensure you specify the programming language and testing framework (e.g., Jest, Pytest) to get syntactically correct code. Over-reliance on mocks can lead to tests that pass but fail to catch integration issues, so balance unit tests with occasional integration checks.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.