Mocks drift.
Production copies leak.
Record masked traffic instead.
Stubsmith records how an API really behaves, failures included, and turns it into deterministic integration tests. Body values are masked in your process.
1. Record real traffic
Shell
$ pip install stubsmithYour app entrypoint
import stubsmith
# key read from STUBSMITH_API_KEY
stubsmith.install()That is the whole integration. Outbound calls are captured from here. Your first test needs a few fields kept; the steps are below.
2. Replay it in your tests
Your test file
import stubsmith
def test_charge():
# one pass per recorded response: the 200, the 402, the real 500
for attempt in stubsmith.replay_all():
with attempt:
result = charge_customer(amount_cents=950_000)
assert result.handledEvery response the API really returned, failures included, served from a bundle stubsmith pull wrote to disk. No API key and no network at test time.
Free plan: 1 seat, 1 project, 50 fingerprints, 3 samples per response variant. No card to sign up. Paid plans from €9 a month, VAT included.
Open source SDKs: Python and Node, MIT. · Supported today: Python captures and replays requests and httpx. Node captures and replays node:http, node:https and global fetch, which covers axios, node-fetch, got and native fetch. Go and Java come later.
From first capture to a green test
Capture
Run your app or tests with the SDK installed. New request shapes appear in Review.
Approve the shape
Until then we store only the shape and a count.
Capture again and replay
Values come back as placeholders (
<masked>,0,false), so a test that checks a status fails, as it should.Keep the fields your test asserts on
Approve a keep rule for each value the test checks, such as
status. The SDK picks up the rule within a minute; capture again, pull, and the test goes green. Which fields to keep.Or pick a placeholder format
For a value you would rather not keep, such as a date, pick a placeholder format in Review. With
STUBSMITH_MASK_SALTset where the SDK runs, replay then gets a valid date instead of<masked>, and the real value never leaves your process.
Replaying a bundle on disk needs no network and no API key.
Your mocks and the API disagree
A mock is written once, from the docs. The API keeps changing and the mock does not, so the suite stays green and the mismatch surfaces in production.
A recording cannot drift, because it is what the API did. If you use VCR.py or pytest-recording, this is the same replay model, without cassette filters to maintain. How the tools compare.
Paste a request. Watch it go .
These are the SDK's masking rules, reimplemented in JavaScript and running in this page on your machine. Nothing is sent anywhere. Edit the payload, approve a keep rule, watch the fingerprint change.
This is the SDK's default output. Format-preserving placeholders are opt-in; the docs list the types and setup. There is no card type: a masked card number stays masked, never reshaped into another card number.
What reaches us
The SDK masks every body value in your process before any network call, and fails closed: on an error it masks everything or drops the capture. Values arrive as sent only for fields you approved a keep rule on, and by default there are none. Two things sit outside the keep rule and are sent as written: a path segment the SDK does not group as an ID, and the few headers a stub needs to replay. The Security page lists exactly what is sent, and why.
Why a service, not a local recorder
A local recorder gives each developer their own cassettes. Stubsmith keeps one approved set for the team:
- Review before anything is stored. New request shapes wait in Review, with no bodies, until an org admin approves them.
- One stub per shape. Fingerprints group traffic by structure; the 429 and the 500 sit next to the 200.
- Paths grouped for you. IDs in URLs are grouped automatically, and the dashboard suggests patterns for slugs.
- The same fixtures in every CI run.
stubsmith pullorfixtures()gives every pipeline the approved stubs. - Deletion handled. Delete captures by endpoint, path or date, or the whole workspace. A masking rule change deletes the samples captured under the old rule.
Hosted on UpCloud and Scaleway in Amsterdam.
In production
Uploads never happen on your request path: one background sender posts each capture, with a 5-second timeout. Masking does run per request: in Python on the calling thread after the response arrives, in Node after your own response handlers have run. If Stubsmith is slow or down, your requests carry on as normal. A capture that fails to send is lost, with no retries, and once the queue (1,000 captures or 32 MiB) is full, new captures are dropped. No errors are raised in your app. A capture over 10 MiB stores no sample, only the shape and a count, with one warning per endpoint, and rate or plan limits log one warning each. A rejected API key is silent unless you set STUBSMITH_DEBUG, so check that your first capture shows up in Review. You can sample a fraction of captures with sample_rate (Python) or sampleRate (Node). On a normal exit the SDK flushes for up to a second, then drops what is left.
Frequently asked questions
- Does Stubsmith see my API bodies?
- Masked bodies and field names; real values only for fields you keep. What reaches us
- Which fields need a keep rule?
- The ones your tests assert on, such as a status or an error code. Each rule is exact: keeping an object does not keep the scalars inside it. Keep only values that are not personal data. Which fields to keep
- What's a fingerprint?
- A request shape: the method, the path template and a digest of the key-paths, query-parameter names and content type. Values enter it only through a variant key, which must be a field you keep. Each plan caps fingerprints; at the cap new shapes are not stored, and we never delete one to make room. How fingerprints work
- How long are samples kept?
- A rolling window per response variant: 3 on Free, 5 on Solo, 10 on Team, 25 on Business. Older samples go as new ones arrive, or within about ten minutes of a masking rule change. Fingerprints and stubs are kept until you delete them.
- Where is my data hosted?
- In the EU: compute and the database on UpCloud in Amsterdam, object storage on Scaleway in Amsterdam, email through Scaleway in Paris. No capture, sample or stub is processed outside the EU or by a US-headquartered provider. Our mailboxes are at Infomaniak in Switzerland; no sample data reaches them. Security details
- How does billing and VAT work?
- The price shown is what you pay, VAT included where it applies. Creem, our merchant of record, handles checkout, VAT and receipts. Cancel any time from the dashboard; annual plans give you 2 months free.
Start with the free plan
One project, 50 fingerprints, no credit card. Try the full flow on one service.