How to mock an API response without a backend

In RequestFox, open a captured call, choose ··· More → Mock this response, then change the status, headers or body in the rule. From then on the page gets your answer instead of the server's, for fetch and XMLHttpRequest, and the call is labelled MOCKED.

Settings, Mock or break an endpoint: rules that make /api/checkout fail with 503 and slow /api/search down, and the form for a new rule
Rules that mock or break endpoints.

Steps

  1. Record the real call once

    Press Start and do what makes the call, so RequestFox has its real status, headers and body to start from.

  2. Choose Mock this response

    Open the call's card, then ··· More → Mock this response, and press Mock it. Every call to that address now gets the same status, headers and body without reaching the server.

  3. Change the answer

    In Settings → Mocks, rules & checks, open the rule and change the status, headers or body to what you want to test: an empty list, an error, a missing field.

  4. Make the call again

    Reload or repeat the action. The page receives your answer, and the card shows MOCKED so nobody files it as a bug.

Break a call instead

Settings → Mocks, rules & checks → Mock or break an endpoint → Add rule…. Give the part of the address to match, a method, and a mode:

  • Fail: answer with an error status you pick.
  • Network error: fail the way a dropped connection does.
  • Slow or Throttle: add a delay, or slow the answer by its size (fetch only).
  • Mock: return the answer you write.
  • Breakpoint (request) or Breakpoint (response): pause the call so you can edit it before it goes on.
  • Cycle: answer differently on each call.

Calls you broke on purpose are labelled SIMULATED.

When you are done

While any rule is on, the recording bar says "Mock & fault rules on". Untick a rule to pause it, or open it and delete it.

With DevTools local overrides

Chrome DevTools can also override a response's content and headers: it saves the overrides as files in a folder you choose. RequestFox keeps its rules in the extension, labels the calls it changed, and can also fail, slow or pause a call. RequestFox vs the DevTools Network panel.

Next