Mock Data & Test Code Generator
A tool that generates dummy data (a JSON array), a MockRepository class that works without a database connection, and Vitest/Jest test code, all from a pasted TypeScript interface or Prisma model — right in your browser.
How to use
- Paste a TypeScript `interface` or a Prisma `model` definition into the input field. You can also try it out with "Load sample".
- Whether it's a Prisma model or a TypeScript interface is detected automatically. If multiple types are found, choose one from "Target type".
- Use "Generation options" to choose the number of records to generate (1–20) and the test framework (Vitest or Jest).
- Switch between the "① Dummy data", "② MockRepository class", and "③ Test code" tabs to review and copy each piece of code.
About this tool
The Mock Data & Test Code Generator produces dummy data, a mock implementation, and test code — all useful for development and testing — from a TypeScript type definition or a Prisma model definition. It's handy when you want to build out the frontend before the backend API is ready, or quickly write database-independent unit tests.
Dummy values are inferred from field names and types — for example, a string field whose name contains "email" gets a value like `user1@example.com`, and a `Date` field gets an ISO-formatted string with the date advancing by one day per record. When a Prisma model is used as input, fields that reference other models (relations) are automatically excluded.
The generated `MockRepository` class implements `findUnique`, `findMany`, `create`, `update`, and `delete` as async methods that operate on an in-memory array, and the generated test code is structured around calling an Express controller factory function that takes the repository as an argument (a dependency injection pattern).
Enter interface User {, id: number;, email: string;, and } on separate lines, then set the count to 1. The dummy data is [{"id":1,"email":"user1@example.com"}]. The email field name influences the generated value, providing starter data for a screen or test.
Values are template examples inferred from types and names, not records retrieved from real users. Unknown types may produce null, and business-specific boundary or failure cases need to be added after copying. Parsing and generation of the JSON and mock class require neither a database connection nor sending your input away.
Frequently asked questions
Does it support both TypeScript and Prisma input?
Yes. If the input contains "interface Name { ... }", it's treated as a TypeScript interface; if it contains "model Name { ... }", it's treated as a Prisma model — the detection is automatic.
Can I fine-tune the generated dummy values?
This tool only auto-generates plausible values based on field names and types — there's no UI for editing individual values. Copy the generated JSON or code and adjust it in your own editor afterward.
Can I run the generated test code as-is?
The test code assumes the existence of an Express router factory function that takes a repository as an argument (`create<Name>Router(repository)`). Adjust the import paths and function names to match your project's actual controller implementation before running it.
Is my input code sent to a server?
No. Parsing the type, generating dummy data, and assembling the code all happen entirely with JavaScript in your browser.