Testing Toolkit
Dev servers and logs, faults, record and replay, mock scenarios and contract checks, cookies, JWTs and types.
Testing Toolkit
Bifurc 0.6 adds tools for the parts of local testing that sit around a request: the servers you run, the failures you need to reproduce, and checking that your mocks still tell the truth.
Dev servers and logs
The Services screen can run your dev servers as well as list what is listening.
- Open Services and add a dev server: its name, command, folder, port, environment variables, and optionally a vault whose secrets it gets as environment variables
- Start, stop or restart it from its row; the state updates live
- Open its log to follow the output, search it, or show only errors and warnings
The output of each server is kept in memory, last 5000 lines. In Capture, the Logs tab of an exchange finds the lines the servers printed while handling that request. Free port on a listener shows the process that holds a port and stops it.
bifurc services define api --cmd "npm run dev" --port 3000 --vault api_keys
bifurc services up --all --wait
bifurc logs api --errors --since 2m
bifurc port free 3000 --kill
Faults
A fault makes the real backend misbehave on purpose, to check retries, timeouts and error screens. It applies to traffic through the forward and reverse proxies.
Open Proxy rules and the Faults tab, then add a fault for a target such as api.localhost/orders:
- Latency: delay each matching request
- Status: answer at once with an error status, for a share of requests
- Drop: never answer
- Reset: close the connection with no answer
The footer shows when faults are active, and clears them. Faults live in the running engine and are gone when it restarts.
bifurc faults add api.localhost/orders --status 503 --rate 30%
bifurc faults add payments.localhost --latency 2s
bifurc faults clear
Record and replay
Recording saves the real answers of chosen hosts, as they pass through the proxy, into a cassette in the workspace. Secrets in headers, query parameters and bodies are masked while recording. Replay later serves the cassette instead of the real hosts.
In Capture, use Record (a name and the hosts) and Stop recording, then Replay to pick a cassette. With passthrough on, requests the cassette has no answer for go to the real host; when you stop, the unmatched requests are listed.
bifurc record start --hosts api.stripe.com --cassette stripe
bifurc record stop
bifurc replay stripe --passthrough
HTTPS hosts need HTTPS interception on.
Mock scenarios and contract checks
- Scenarios. Mocks for the same method and URL are scenarios of one another. The scenario bar on an open mock switches which one answers.
- Hits. An open mock shows how many times it answered.
- Serve on a port. Serve the workspace's mocks over plain HTTP on a port of their own, for a client you cannot point at the proxy.
- Contract check. Check contract on a mock sends its paired real request and lists where the real answer has drifted from the mock. Check all does it for every mock, or a folder's. A check sends the real requests, including POST and DELETE, so point it at a server where that is safe.
- CORS. Mocks answer cross-origin pages with CORS headers for the request's origin, and answer preflights for mocked calls.
bifurc mocks serve --port 4010
bifurc contract check
Cookies, JWTs and types
- The Cookies tab of a response lists every cookie with its attributes, and decodes a JWT value into its header and payload, with expiry times and an Expired tag. The signature is not verified.
- The Types panel in the right sidebar infers TypeScript, Zod, Python or Go types from a saved request's JSON responses.
bifurc jwt decode --from-jar api.localhost
bifurc jwt mint --key-from-vault auth --claims '{"role":"admin"}' --exp 5m
bifurc types "Get order" --lang zod
bifurc openapi infer --out openapi.yaml