UUID Use Case

UUID Mock ID

When mocking an API, give its resources UUID IDs so your stubs behave like the real thing.

Stub-safeUniquev4

Generated locally with the Web Crypto API — nothing leaves your browser.

What Is UUID Mock ID?

How to generate

  1. Assign UUIDs in your mock server's responses.
  2. Keep a map from mock id to canned object.
  3. Never reuse a production-shaped id in mocks.

Use Cases

Code Examples

JavaScript
const id = crypto.randomUUID();
Python
import uuid
id = uuid.uuid4()

Frequently Asked Questions

Mock ID format matter?
It should match what the real service returns (UUIDs, here) so tests do not encode wrong assumptions.
Reuse mock IDs across tests?
Prefer fresh per test run to avoid stateful coupling, unless a test pins a specific value.

Related tools