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?
- A mock ID stands in for a real external identifier. A UUID keeps mocks realistic and distinct from production values.
- This prevents a test that accidentally talks to the real service from clashing with mock data.
How to generate
- Assign UUIDs in your mock server's responses.
- Keep a map from mock id to canned object.
- Never reuse a production-shaped id in mocks.
Use Cases
- Contract testing.
- Offline development.
- Chaos simulation.
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
UUID v1 GeneratorUUID v3 GeneratorUUID v4 GeneratorUUID v5 GeneratorUUID v6 GeneratorUUID v7 GeneratorUUID v8 GeneratorBulk UUID GeneratorShort UUID GeneratorUUID ValidatorUUID FormatterUUID as a Primary KeyUUID Database IDUUID Foreign KeyUUID Shard KeyUUID Partition KeyUUID in a Composite KeyUUID Surrogate KeyUUID API KeyUUID Session TokenUUID Access TokenUUID Refresh TokenUUID Idempotency KeyUUID Request IDUUID Correlation IDUUID Trace IDUUID CSRF TokenUUID NonceUUID FilenameUUID Object KeyUUID S3 KeyUUID Upload IDUUID Cache KeyUUID Blob NameUUID Temp FileUUID User IDUUID Account IDUUID Customer IDUUID Device IDUUID Tenant IDUUID Client IDUUID Anonymous IDUUID Member IDUUID Message IDUUID Event IDUUID Job IDUUID Task IDUUID Queue Message IDUUID Transaction IDUUID Order IDUUID Invoice IDUUID Payment IDUUID Reset TokenUUID Verification TokenUUID Invite CodeUUID API SecretUUID Share LinkUUID Magic LinkUUID Node IDUUID Worker IDUUID Lock IDUUID Cluster IDUUID Test DataUUID Seed DataUUID FixtureUUID Mock IDUUID Placeholder IDUUID Sample ID