Mock outside services in tests
Picks a mock, stub or test container for each outside service, so tests stay isolated and no real calls escape.
What we improved
Brought the working code into SKILL.md. The original's SKILL.md described each tool and pointed at reference files for every line of code. It now carries a complete MSW setup (handlers with error variants first, a shared server module, the
Improved by YourAISkill from the original by petrkindlmann, under its MIT licence. The download includes the author's licence and a CHANGES.md listing every change. Both Claude reviews read the improved version.
Claude's review
8/10 Thorough isolation strategy with working MSW, Playwright route guard, WireMock, Testcontainers and Toxiproxy recipes, handler-order and state-reset gotchas, and cassette expiry.
We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.
In detail
Decision framework for isolating every external dependency in a test suite: when to use in-process mocks, HTTP stubs (MSW, WireMock), record-replay, fault injection (Toxiproxy), or ephemeral real services (Testcontainers), and how to enforce that no real calls escape in CI. Use when: "mock service," "stub API," "fake service," "WireMock," "MSW," "Toxiproxy," "test isolation," "dependency management," "stub an external API in CI." Not for: consumer-driven contract verification (Pact, broker) — use contract-testing; standing up a full Docker Compose env or seed data — use test-environments; broad resilience/game-day fault campaigns — use chaos-engineering. Related: contract-testing, test-environments, api-testing, test-data-management, chaos-engineering.
How you use it
- Add it to your pack, then download your pack (1 credit).
- In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
- Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide
Safety check
Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.
An automated scan lowers risk but cannot promise zero risk. How we check skills
Preview
The first lines of SKILL.md
---
name: service-virtualization
description: >-
Decide how to isolate every external dependency in a test suite and set it up: in-process
mocks, HTTP stubs (MSW, WireMock, Playwright page.route), record-replay cassettes with expiry,
fault injection (Toxiproxy), or ephemeral real services (Testcontainers), plus a CI guard that
fails the run when a request escapes the stubs. Includes working MSW, Playwright, WireMock,
Testcontainers and Toxiproxy setups. Use when asked to mock or stub an external API, fake a
service, stop tests hitting real third parties, test timeouts and rate limits, or wire stubs
into CI. Not for consumer-driven contract verification with a Pact broker, standing up a whole
Docker Compose environment with seed data, or game-day chaos campaigns.
license: MIT
metadata:
author: kindlmann
version: "2.0"
category: infrastructure
---
<!-- Modified by YourAISkill (youraiskill.com) on 2 December 2026 from the original by petrkindlmann. See CHANGES.md. -->
# Service Virtualization
Mock Stripe at the SDK layer and your tests pass green while production returns 500 the moment Stripe changes a response field, because the stub was never tied to a contract. This skill picks the right isolation strategy per dependency (in-process mock, HTTP stub, record-replay, fault injection or ephemeral real service), stubs at the HTTP layer so tests survive SDK upgrades, and makes the CI run fail when a request escapes the stubs.
## Quick route
| Situation | Use |
|---|---|
| Node or jsdom test calling an external HTTP API | MSW (recipe below, full version in `references/msw.md`) |
| Playwright driving a page that calls its own backend under `/api/*` | `page.route` with an unhandled-request guard (below). MSW browser mode needs the app to serve `mockServiceWorker.js`, which a frozen build does not |
| Polyglot CI, complex matching, or a standalone stub server | WireMock (`references/wiremock.md`) |
| Database, cache or queue | Testcontainers (`references/testcontainers.md`) |
| Timeouts, latency, connection resets | Toxiproxy (`references/toxiproxy.md`) |
| Bootstrapping stubs from a real API, or a multi-step baseline | Record-replay (`references/record-replay.md`) |
| GitHub Actions wiring | `references/ci.md` |
| Not sure | Decision tree below |
## Discovery questions
If the project already documents testing conventions (a testing README, an existing `mocks/` folder, a shared handler file), follow them and skip what they answer. Otherwise ask:
...From petrkindlmann's repository, MIT licence.
Related skills
-
Checked
React Native testing
Writes React Native Testing Library tests the right way for v13 and v14, so tests stay fast and reliable.
8/101 credit -
Checked
JUnit and Mockito tests
Writes and fixes Java tests with JUnit, AssertJ and Mockito that are deterministic and keep failures visible.
8/101 credit -
Checked
Test code review
Reviews new or changed tests in pytest, Jest, Go and more, so weak tests are caught before merge.
7/101 credit -
Checked
Go table driven tests
Writes Go tests with table cases, fakes, fuzzing, benchmarks and golden files that stay fast and reliable.
8/101 credit -
Checked
MSTest Unit Testing
Writes modern C# unit tests with current MSTest APIs, assertions, data driven tests and lifecycle patterns.
8/101 credit -
Checked
Quarkus Testing
Writes and fixes Quarkus tests using Dev Services containers, with the right profiles, mocks and run commands.
7/101 credit