Fixtures in your test runner

Set STUBSMITH_API_URL and STUBSMITH_API_KEY before running tests, or pass them as keyword arguments to stubsmith.fixtures()(options to fixtures() in Node). In Python the call is a blocking fetch at pytest collection time; in Node it is async, and the same code runs under node:test, jest or vitest with their own test.

import pytest
import stubsmith

fixtures = stubsmith.fixtures("POST /v1/charges/{id}", distinct="status")

@pytest.mark.parametrize("fx", fixtures, ids=lambda f: str(f.status))
def test_handles_every_recorded_response(fx):
    body = fx.response.json()
    # assert your application contract against body and fx.status
    ...
import { test } from "node:test";
import { fixtures } from "stubsmith";

const recorded = await fixtures("POST /v1/charges/{id}", { distinct: "status" });

for (const fx of recorded) {
  test(`handles a recorded ${fx.status}`, () => {
    const body = fx.response.json();
    // assert your application contract against body and fx.status
  });
}

This fetches at collection time, so it needs a project key wherever the tests run, and it stubs nothing: you assert against the fixture yourself. To have your real client code answered from recordings with no key and no network, see offline replay, which also covers looping every recording rather than one per status.

Without distinct="status" the call returns individual captures, newest first, capped at 100 and defaulting to 20. A test that parametrizes over many samples without raising limit is silently working from the first 20.

Pattern resolution note: passing a path containing {param} segments resolves only against configured request types that have a matching pattern. Passing a concrete path (e.g. /v1/charges/ch_abc123) is resolved against an exact (non-dynamic) request type first, then against a pattern-based request type via segment matching, falling back to an exact path match on captures if no request type is configured.