Mock API for testing
A mock API for testing gives your frontend or your tests a real URL to call, without a real backend. With Mockify you describe the data you need and get a temporary endpoint that returns realistic JSON.
Try it nowWhy use a mock API for testing
Tests that call a real backend are slow, and they fail when the server is down or the data has changed. Tests with data typed into every test file are hard to read and look nothing like a real response.
A mock API sits in the middle. Your code sends a real HTTP request, so loading states, parsing and error handling are all exercised. The answer is data you chose. The same URL returns the same records every time until the endpoint expires, which makes checks like “the list shows 8 rows” easy to write.
How to set up a mock API for testing with Mockify
- Write down the response your test needs: which fields, and how many records.
- In the generator, describe it in the prompt. If a test depends on exact key names and types, add your own fields (up to 15) and pick a type for each.
- Press Generate and put the endpoint link in your test or in an environment variable.
Paste this prompt into the generator, or press the button to have it filled in for you:
8 orders with order_id, customer_name, total, status (paid, pending or cancelled) and order_date
Example output
This example was written by hand to show the shape of the data. Your result will have different values.
[ { "order_id": "ORD-1042", "customer_name": "Sara Nielsen", "total": 84.5, "status": "paid", "order_date": "2025-09-03" }, { "order_id": "ORD-1043", "customer_name": "Tomás Oliveira", "total": 19.99, "status": "pending", "order_date": "2025-09-04" } ]
Call the mock API from a test
This works in Jest or Vitest on Node 18 or newer, or in any test runner that has fetch. Replace YOUR_ID with the id from your own endpoint link.
const API_URL = "https://www.mockify.online/api/mock/YOUR_ID";
test("every order has an id and a numeric total", async () => {
const res = await fetch(API_URL);
const { data } = await res.json();
expect(res.status).toBe(200);
expect(data.length).toBeGreaterThan(0);
data.forEach((order) => {
expect(order.order_id).toBeDefined();
expect(typeof order.total).toBe("number");
});
});When to use something else
A Mockify endpoint lasts 6 hours, or 24 hours if you extend it once. That is fine for manual testing, demos and quick checks, but not for a test suite that runs every day in CI: the URL will be gone. For that, keep the JSON in your repository and serve it with a mocking library such as Mock Service Worker (MSW), or run a small local server. Also note that the endpoint is read-only: it cannot test creating, updating or deleting records.