Mock Data Generator for VS Code
Generate high-quality mock data for your models directly in Visual Studio Code. This extension analyzes your TypeScript, JavaScript, Prisma, Mongoose, and TypeORM models to create realistic data for development and testing.

Features
- 🔍 Automatic Model Detection: Analyzes your codebase to find models
- 🔄 Relationship Analysis: Maintains referential integrity between related models
- 🌐 Contextual Data: Generates field values based on names and types
- 📊 Multiple Formats: Output as JSON, SQL, CSV, GraphQL, TypeScript, and more
- 💾 Database Population: Directly populate MySQL, PostgreSQL, SQLite, MongoDB, and other databases
- 📝 Smart Constraints: Field constraints from comments and decorators
- 🌍 Localization: Region-specific data generation
- 📈 Visualization: Interactive model diagrams
- 🔧 Customizable: Extensive configuration options
Installation
- Open VS Code
- Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X)
- Search for "Mock Data Generator"
- Click Install
- Reload VS Code
Quick Start
- Open your project folder in VS Code
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
- Type "Mock Data Generator: Generate Mock Data"
- Enter the number of records to generate
- Select the output format
- Done! The generated data will open in a new editor tab
Supported Models
The extension automatically detects models from:
Model Type |
File Extensions |
Notes |
TypeScript Interfaces |
.ts, .tsx |
With or without decorators |
TypeScript Classes |
.ts, .tsx |
With or without decorators |
JavaScript Classes |
.js, .jsx |
With JSDoc annotations |
Prisma Schema |
.prisma |
All Prisma models |
Mongoose Schema |
.js, .ts |
mongoose.Schema definitions |
TypeORM Entities |
.ts |
@Entity decorated classes |
Sequelize Models |
.js, .ts |
sequelize.define or Model.init |
Format |
Description |
JSON |
Structured JSON data |
SQL |
Database INSERT statements |
CSV |
Comma-separated values |
GraphQL |
Queries and mutations |
TypeScript |
Interface declarations with data |
API Mock |
REST API response format |
Excel |
XLSX spreadsheet |
Database |
Direct database population |
Database Support
Database |
Connection Type |
Features |
MySQL |
Native driver, Docker |
Table creation, data population |
PostgreSQL |
Native driver, Docker |
Schema support, JSON types |
SQLite |
Native driver |
File-based, in-memory |
MongoDB |
Native driver, Docker, Atlas |
Collection creation, documents |
SQL Server |
Native driver, Docker |
Table creation, data population |
Oracle |
Native driver |
Table creation, data population |
Database Connection Methods
The extension supports multiple ways to connect to databases:
Local Connections
Connect to databases running on your local machine or network:
- Select the database type
- Enter connection details (host, port, credentials)
- The extension will test the connection before proceeding
Docker Integration
The extension can create and manage Docker containers for databases:
- Run
Mock Data Generator: Create Database Container
- Select the database type (MongoDB, MySQL, PostgreSQL)
- Configure container settings
- The extension will create a container and provide connection details
You can also generate a Docker Compose file with Mock Data Generator: Generate Docker Compose File
.
Cloud Database Connections
Connect to hosted database services:
MongoDB Atlas
For MongoDB Atlas connections, you can use the connection string directly:
- Select MongoDB as the database type
- Choose "Connection String" as the connection method
- Paste your MongoDB Atlas URI (
mongodb+srv://username:password@cluster.mongodb.net/...
)
No additional details are required when using a connection string.
Other Cloud Providers
For other cloud database providers:
- Select the database type
- Enter the host address provided by your cloud service
- Enter port, credentials, and other required information
Connection Security
- All database credentials are used only for the current session
- SSL/TLS connections are supported for all database types
- Connection strings with embedded credentials are masked in the UI
For more detailed information about database connections, see database-connections.md and docker-setup.md.
Example
Given a simple TypeScript interface:
interface User {
id: number;
firstName: string;
lastName: string;
email: string;
age: number;
isActive: boolean;
createdAt: Date;
profile: {
bio: string;
avatarUrl: string;
};
}
The extension will generate realistic data:
{
"User": [
{
"id": 1,
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"age": 32,
"isActive": true,
"createdAt": "2023-08-15T14:30:45Z",
"profile": {
"bio": "Full-stack developer with 8 years of experience",
"avatarUrl": "https://example.com/avatars/johnsmith.jpg"
}
}
// More records...
]
}
Extension Settings
This extension contributes the following settings:
mockDataGenerator.recordsPerModel
: Default number of records to generate per model
mockDataGenerator.seed
: Random seed for reproducible generation
mockDataGenerator.modelFilePatterns
: Glob patterns for model files
mockDataGenerator.excludePatterns
: Glob patterns for files to exclude
mockDataGenerator.excludedModels
: Models to exclude from generation
mockDataGenerator.excludedFields
: Fields to exclude from generation
mockDataGenerator.useContextualData
: Enable field name-based contextual data
mockDataGenerator.localization.enabled
: Enable locale-specific data generation
mockDataGenerator.localization.locale
: Default locale for data generation
mockDataGenerator.logLevel
: Controls logging verbosity
Commands
Command |
Description |
mockDataGenerator.generateMockData |
Generate mock data from models |
mockDataGenerator.visualizeModels |
Create visualization of models and relationships |
mockDataGenerator.configureExtension |
Open settings for the extension |
mockDataGenerator.checkDocker |
Check if Docker is available on your system |
mockDataGenerator.createDatabaseContainer |
Create a Docker container for database testing |
mockDataGenerator.generateDockerCompose |
Generate a Docker Compose file for databases |
Production Readiness
The Mock Data Generator extension is built with production-grade quality and reliability in mind:
Testing and Quality Assurance
- Comprehensive Test Coverage: Extensive unit and integration tests for all core functionality
- TypeScript Type Safety: Full TypeScript implementation with strict type checking
- Error Handling: Robust error handling with detailed logging and user-friendly error messages
- Continuous Integration: Automated testing via GitHub Actions for every pull request and push
- Optimized Generation: Efficient algorithms for generating data even for complex model structures
- Memory Management: Careful memory handling to minimize memory footprint
- Batch Processing: Support for generating large datasets through batch processing
- Caching: Strategic caching to improve performance for repeated operations
Reliability and Error Recovery
- Graceful Degradation: Falls back to simpler generation strategies when advanced features are unavailable
- Defensive Programming: Extensive input validation and defensive coding practices
- Detailed Logging: Configurable logging levels for troubleshooting and debugging
- Recovery Mechanisms: Automatic recovery from common error conditions
Security
- Secure By Default: No network calls for standard operations
- Database Connection Security: Support for secure database connections with credential management
- No Telemetry: Does not collect or transmit any user data
- Input Validation: Thorough validation of all inputs to prevent injection attacks
Documentation and Support
- Comprehensive Documentation: Detailed user guide, API documentation, and examples
- Interactive Examples: Visual examples and tutorials for common use cases
- Regular Updates: Ongoing maintenance and feature improvements
- Community Support: Active issue tracking and community engagement
Documentation
For detailed usage and advanced features, see the USAGE.md file.
Changelog
See the CHANGELOG.md for details about each release.
Contributing
We welcome contributions to the Mock Data Generator extension!
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for your changes
- Make sure all tests pass with
npm test
- Submit a pull request
See CONTRIBUTING.md for more details.
License
This extension is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with TypeScript
- Uses Faker.js for data generation
- Database connectors powered by popular Node.js drivers
Privacy and Telemetry
The Mock Data Generator extension does not collect any personal data or telemetry.
Support
If you encounter any issues or have questions, please create an issue on the GitHub repository.
Recent Improvements
Database Verification
- Added database record count verification to ensure data is actually inserted
- Enhanced error reporting for database operations with specific error cases
- Improved the success message to confirm data insertion with verification
- Fixed issue where success message could be shown even when data wasn't inserted
MongoDB Improvements
- Added explicit MongoDB collection creation to handle empty/new databases
- Fixed issue where tables were skipped instead of created for new databases
- Implemented template document approach to establish collection structure
- Improved column detection for empty collections to allow data population
- Enhanced error logging with more detailed diagnostics
- Fixed issue where empty error objects were incorrectly reported after successful operations
Enjoy generating mock data!