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
| Option | Meaning |
|---|---|
| URL contains | The requests whose address contains this text. |
| Method | One method (GET, POST…) or all of them. |
| Respond with | The answer you decide: status, body, content type and headers. An invalid JSON body shows a warning. |
| Fail | The request fails with a network error, as if the server were unreachable. |
| Delay | The request reaches the real server, late. |
| First N requests | Only 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.
Something unclear or missing? Write to info@actify-studio.com.