---
title: "Mocking Backends | Speedscale Docs"
description: "Mock backends during testing with Speedscale to reduce dependencies on external APIs and ensure reliable API interactions without real transactions."
canonical: "https://docs.speedscale.com/guides/replay/mocks/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/replay/mocks/index.md) | [Canonical page](https://docs.speedscale.com/guides/replay/mocks/)

# Mocking Backends

During a replay

Mocks, backed by [responders](https://docs.speedscale.com/reference/glossary/#responder), can be turned on and off before a replay, or from the snapshot. This page describes the basic interaction with mocks.

<a id="viewing-the-snapshot"></a>

## Viewing the snapshot

Open the snapshot's **Overview** tab to inspect its **Mocks** card. In **Traffic**, select **Mocks** or one dependency to inspect the recorded calls and responses. See [View Snapshot](https://docs.speedscale.com/guides/creating-a-snapshot/#view-snapshot) for the snapshot layout.

![The banking-gateway snapshot Mocks card with four recorded dependencies](https://docs.speedscale.com/assets/images/overview-mocks-f87f4b7795da195692ae8f2639edbff8.jpg)

[Open screenshot full size](https://docs.speedscale.com/assets/images/overview-mocks-f87f4b7795da195692ae8f2639edbff8.jpg)

This banking example records calls to Redis, accounts, transactions and user services. The Mocks card shows the number of recorded requests and detected technology for each dependency. [Responders](https://docs.speedscale.com/reference/glossary/#responder) use that recorded traffic to answer the application during a replay. See [supported technologies](https://docs.speedscale.com/reference/technology-support/).

<a id="choose-mocks-for-a-replay"></a>

### Choose mocks for a replay

The following replay-setup example uses a different `payment` service with DynamoDB, Stripe, Hubspot, Plaid and Google Cloud dependencies. Its backend selector controls which dependencies are mocked for that replay.

![The replay setup backend selector, listing dependencies and their detected technologies](https://docs.speedscale.com/assets/images/table-da6f741ea06723b588e6adb265563644.png)

We can also see here that Speedscale has identified the type of backends these are. For eg. Hubspot is a JSON API and Stripe is similar but we've also identified `Bearer` authorization for the API requests. At this point we could uncheck certain backends if we did not them mocked out. For eg. I may not want to mock out DynamoDB because I have a dev instance setup but I want to mock out Stripe because I don't want to make actual credit card transactions. For now, we'll leave these all checked.

<a id="run-a-replay"></a>

## Run a replay

![Replay](https://docs.speedscale.com/assets/images/replay-32edbcdc1be004740bdbecda6885e843.png)

Now we can run a replay with the **Replay** button, or choose **How to replay** from the menu beside it for the other ways shown here. Note that by default, both inbound and outbound traffic is generated and mocked respectively. If you want to run a workload with just the mocked backend for development but not run a full test replay, skip to [responder only mode](https://docs.speedscale.com/guides/replay/mocks/#responder-only).

![Report](https://docs.speedscale.com/assets/images/report-01fdfe2534fb862ec9610cc9daef8c52.png)

After the replay is done, we can see the corresponding report. We have a 100% passing report and more importantly, we have a 100% responder rate. This means that we were successfully able to match all the requests made by the service under test via our signature matching algorithm. We can inspect the request and response pairs seen by the responder the same way we would with our general traffic capture.

<a id="responder-only"></a>

## Responder Only

If we want to mock our backends indefinitely and not run a test, we can do this using responder only mode. Depending on your method of choice you can set the mode either via the annotation `replay.speedscale.com/mode: responder-only` or if you're using the TrafficReplay CRD, by setting the field `mode: responder-only`. This is a great way to develop services with external dependencies that:

*   Have a cost associated with each API call. For eg. certain information APIs can cost a few cents per request which can add up quickly during development.
*   Have disruptive side effects. For eg. we do not want to ever make real credit card charges and always want to mock out Stripe's API.
*   Have low rate limits. Many public APIs such as Github's has strict rate limits which can be irritating to face when doing rapid iteration.

<a id="disabling-some-mock-responses"></a>

## Disabling some mock responses

Sometimes you don't want to mock everything in the environment. There are three ways to accomplish this:

1.  _Disable an entire mock_ - You can accomplish this by turning off the mock by unchecking it in the replay wizard: ![ReplayMockDisabled](https://docs.speedscale.com/assets/images/replay_mock_disabled-219d75631669b4b9157bddaeb61fa642.png)
    
2.  _Allow passthrough requests_ - If you want to mock known requests but allow unrecognized transactions to continue to the original destination you can use `passthrough` mode. Just check the passthrough operation in your test config under the Mocks section: ![TestConfigPassthrough](https://docs.speedscale.com/assets/images/tc_passthrough-6dec62bbe5db320c4e9e4205d08a51a0.png)
    
3.  _Disable the responder_ - If you want all mocks to be disabled, regardless of snapshot configuration, set your test config for "Tests only" mode. ![TestsOnly](https://docs.speedscale.com/assets/images/test_only-ef04b21f6d6b025aaf1e6661e09e4fb5.png)
