Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

service-virtualization

БесплатноБез исполняемых скриптовНе проверен

Decision framework for isolating every external dependency in a test suite: when to use in-process mocks, HTTP stubs (MSW, WireMock), record-replay, fault…

petrkindlmannот petrkindlmann★ 317 звёзд на GitHub

Об этом скилле

Mock Stripe at the SDK layer and your tests pass green while production 500s 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 any real call escapes the stubs.

Quick Route

Situation Go to
Node/browser test hitting an external HTTP API MSW → references/msw.md
Browser page driven by Playwright, calling its own backend under /api/* page.route in the test runner (reverse registration order, route.fallback() to chain, an unhandled-request guard that aborts and logs); MSW browser mode needs the application to serve mockServiceWorker.js, which a frozen build does not. Cassettes: references/record-replay.md
Polyglot CI, complex matching, or you need a standalone stub server WireMock → references/wiremock.md
Dependency is a DB / cache / queue Testcontainers → references/testcontainers.md
Testing 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
Wiring any of these into GitHub Actions references/ci.md
Not sure which to reach for Decision Tree (below)

Discovery Questions

Check .agents/qa-project-context.md first — if it exists and is filled in, use it (an unfilled template answers nothing), respect existing mocking conventions, and skip anything answered there. Then:

  • How many external dependencies does the system call, and which are painful in tests? Rate-limited, slow, flaky, or paid dependencies are the highest-priority virtualization candidates; list payment, email, auth, and third-party data sources.
  • What testing levels need isolation? Unit tests want fast in-process mocks; integration tests want HTTP-level stubs; E2E wants real or containerized services — the level sets the strategy.
  • Does the provider offer an official test mode or sandbox? Stripe test mode, Twilio test creds, etc. beat any home-grown stub for fidelity — prefer them where they exist.
  • Do you have contracts with these dependencies? If yes, contract tests keep stubs in sync; see contract-testing. If no, mocking what you don't own is a known risk (Core Principle 3).
  • Docker available in CI? No Docker steers you to MSW (in-process); Docker unlocks WireMock, Testcontainers, and Toxiproxy.

Core Principles

1. Match the isolation level to the confidence you need. Unit tests can mock aggressively — they test internal logic. Integration tests should use realistic stubs or real services because they test boundaries. E2E should run the closest thing to production that is still reliable.

2. Real services beat fakes when they're fast, free, and reliable. A local PostgreSQL container gives more confidence than a fake and costs little — prefer it. Reserve fakes for dependencies that are slow, unreliable, or paid.

3. Never mock what you don't own without a contract — and prefer the provider's test mode. If you stub Stripe and Stripe changes its response shape, your tests stay green while production breaks. In order of preference: use the provider's official test mode/sandbox (Stripe test mode, Twilio test creds) → an HTTP stub validated by a contract test for drift → a bare stub only when nothing better exists. See contract-testing.

4. Stubs must fail realistically. A stub that always returns 200 never exercises error handling. Every stub needs error variants: 429 rate limits, 500s, timeouts, malformed bodies.

5. One abstraction layer between test and tool. Wrap MSW handlers, WireMock stubs, and Testcontainers setup behind a consistent interface so switching tools doesn't mean rewriting tests.


Decision Framework

When to use each isolation strategy

Strategy Speed Fidelity Complexity Best for
In-process mock Fastest Lowest Trivial Unit tests, isolating internal modules
HTTP stub (MSW) Fast Medium Low Frontend/Node tests hitting external APIs
HTTP stub (WireMock) Fast Medium-High Medium Language-agnostic, complex matching rules
Record-replay Fast after first run High initially, decays Medium Bootstrapping stubs from real APIs quickly
Service fake Medium High High Stateful dependencies (in-memory DB, fake auth)
Ephemeral real (Testcontainers) Slower Highest Medium Databases, message queues, caches
Shared real service Slow Production-level Low (to set up) Staging validation, final pre-deploy check

Decision tree

Is the dependency internal to your codebas
Полный SKILL.md на GitHub

Установить service-virtualization в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/ci.mdreferences/msw.mdreferences/record-replay.mdreferences/testcontainers.mdreferences/toxiproxy.mdreferences/wiremock.md

FAQ

Что делает скилл service-virtualization?

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.

Как установить скилл service-virtualization?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл service-virtualization запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить service-virtualization с