---
title: "Using Transforms for better Mocks | Speedscale Docs"
description: "Learn how to edit signature mocks in Speedscale to enhance your API testing and streamline your development process. This guide provides clear instructions and best practices for effectively managing mocks within your applications."
canonical: "https://docs.speedscale.com/guides/replay/mocks/edit-sig/"
---

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

# Using Transforms for better Mocks

<a id="prerequisites"></a>

## Prerequisites

1.  You have [created a snapshot](https://docs.speedscale.com/guides/creating-a-snapshot/)
2.  You know how to [run a replay](https://docs.speedscale.com/guides/replay/)

<a id="replay-without-transforms"></a>

## Replay without Transforms

For this guide, we're going to use this very simple snapshot for an app that uses Google Spanner as a database. This snapshot has two inbound calls to `/player` and `/score` that use Spanner and we are purposefully not including any other traffic to this app for this demo.

![Snapshot](https://docs.speedscale.com/assets/images/snapshot-b65e5bdade2140a12c5b5f87be37cd68.png)

We run a replay with this snapshot and no special settings. This report has a 0% accuracy.

![Failed Report](https://docs.speedscale.com/assets/images/failed-report-773cbe78b53ccfbe60d3c6ed3622da86.png)

We notice that besides the accuracy being low, the Mock response rate is also not 100%. For some apps this may be normal but given how simple our test is, we want to know why.

![Responder](https://docs.speedscale.com/assets/images/responder-miss-809fa1ee6829655282d66ca6bb12eae2.png)

Inspecting this `No Match` call to spanner, we see that field 11 in the body contains a value that looks like a constantly changing value, in this case the name of the pod that made the request. Upon further inspection of the protobuf for this request, we see that field 11 is `RequestOptions`.

![Proto](https://docs.speedscale.com/assets/images/proto-message-854bd5b0c311fde0df30d962dad9b5c6.png)

And we see that the field itself contains a bunch of settings that are dynamic.

![Field](https://docs.speedscale.com/assets/images/proto-field-1070921612e7a3a65faddc649d5c6525.png)

We could transform the snapshot to always set that pod name to a constant and that may be good enough for this case. But to future proof this, it would be safer to completely ignore a field with dynamic information like this.

<a id="transform"></a>

## Transform

Open the snapshot's **Traffic** tab and select **Mocks**. Find a request to `/google.spanner.v1.Spanner/ExecuteStreamingSql` and open its request body.

![Request body](https://docs.speedscale.com/assets/images/pre-delete-b2cd806408f32bf3e4e409fa644dfc6d.png)

Use the field's transform action to open the chain in **Prepare**. For this example, extract the request body and add **JSON Delete** with `path` set to `fieldsMap.11`. This removes the dynamic RequestOptions field before the responder matches the request.

![The JSON Delete path field set to fieldsMap.11](https://docs.speedscale.com/assets/images/json-delete-2764dbae38bee8f5d1f69b51401d6b8c.jpg)

[Open screenshot full size](https://docs.speedscale.com/assets/images/json-delete-2764dbae38bee8f5d1f69b51401d6b8c.jpg)

Check the chain preview against the recorded request, then select **Done** and **Save and reanalyze**. Keep the path specific to this example; other protobuf messages can use a different field number.

Now you can see that this field is completely removed from the request body.

![Request body](https://docs.speedscale.com/assets/images/post-delete-58370c4195887effeeab01a6b1da6062.png)

<a id="replay-with-transforms"></a>

## Replay with Transforms

Now we run another replay with the transformed snapshot.

![Success](https://docs.speedscale.com/assets/images/success-f9a65ba9cdb3c7a040b2ba8c7b3fce83.png)

We have 100% Mock rate and also 100% accuracy! Our replay behaved exactly like our app did when we did our initial recording and we didn't have to use an actual Google Spanner instance where the data might have changed since our recording.

Transforms are extremely powerful for parameterizing and modifying dynamic data. Lots of data that we use in our apps is static but there are always things like timestamps, session ids, environment tags, etc. that we need to control for in tests and Transforms help us do exactly that on the inbound and outbound side.
