Skip to content
API & network

Mocking requests

Answer, fail or delay the requests you choose, to test server errors, empty lists and slow answers on demand.

A Mock request step changes what the server answers from that point of the test onward. Use it to see how your site behaves with a server error, an empty list or a slow response, without waiting for them to happen.

Add a mock

  • In the Action History, hover the gap between two steps and click + → Insert mock.
  • Or, in the Network tab, select a call and click Mock: the step starts from the real response, ready to change.

What a mock can do

OptionMeaning
URL containsThe requests whose address contains this text.
MethodOne method (GET, POST…) or all of them.
Respond withThe answer you decide: status, body, content type and headers. An invalid JSON body shows a warning.
FailThe request fails with a network error, as if the server were unreachable.
DelayThe request reaches the real server, late.
First N requestsOnly the first N matching requests; the next ones go to the server.

Where mocks work

  • In Headless runs on Chromium, Firefox and WebKit, and In-App.
  • While the test is open, also in the app’s browser: the Network tab shows N mocks active, and calls answered by a mock have the Mocked badge.
  • Manual Steps and Gherkin describe the mock in one line.
Mocking requests — Actify Studio Docs