Recipe · Testing

Stable, seeded fake data for your tests

If your snapshot test asserts « Forged Hammer — €24.90 » and the fixture re-rolls tomorrow, the test fails for no reason. MockSmith generates data from a seed, so the same project returns the same records, run after run.

Updated June 7, 20264 min

Seeded by default

Generation runs through a seeded random generator tied to the project. The first record of products is the same string today, tomorrow and in CI. You assert on real values without hardcoding a live backend.

Stable order, too

Collections come back oldest-first, always in the same order. So data[0] in a paginated list is deterministic — perfect for « the first row should be… » assertions.

Tests that mutate — and clean up

Your tests POST, PATCH and DELETE against the mock, which changes its state. Two ways to keep runs isolated:

  • Undo what you write — delete the records your test created in a teardown step.
  • Scheduled reset (Pro) — have the project regenerate from its seed every hour or every day, wiping mutations back to the pristine dataset automatically.

A clean pattern

01

Read-only assertions

Assert on seeded GET data directly — it never changes.

02

Write in isolation

Use a dedicated project (or resource) for tests that create records.

03

Reset

Schedule a daily reset, or delete-on-teardown, so the next run starts clean.

vitest / jest
const base = "https://mocksmith.lioncore.dev/m/you/shop"; test("first product is stable", async () => {  const res = await fetch(`${base}/products?limit=1`);  const { data } = await res.json();  // deterministic: safe to snapshot  expect(data[0].name).toMatchSnapshot();});

Frequently asked

Is the data stable on the free plan?

Yes — seeding and stable ordering apply to every plan. Only the automatic scheduled reset is a Pro feature; on free you reset by re-generating manually or cleaning up in your tests.

If I regenerate the project, do I get the same data?

Yes, as long as the spec and seed are unchanged. Editing the spec (new field, different count) changes what's generated — intentionally.

Can I run tests in parallel against one mock?

Read-only tests, yes — concurrent GETs don't interfere. For write tests, isolate them (separate resources or projects) so they don't fight over the same records.

Stop waiting on the backend.

Forge your own mock API in two minutes. Free, up to two projects, no credit card.

Forge a free mock

Read next