IDE Integration
MockForge provides first-class IDE integration to enhance your development workflow. This guide covers the VS Code extension and its features.
VS Code Extension
The MockForge VS Code extension brings the power of MockForge directly into your editor, providing real-time mock management, validation, and preview capabilities.
Installation
Install the extension from the VS Code Marketplace:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for “MockForge”
- Click Install
Or install via command line:
code --install-extension saasy-solutions.mockforge-vscode
Configuration
Configure the extension in VS Code settings:
{
"mockforge.serverUrl": "http://localhost:3000",
"mockforge.autoConnect": true,
"mockforge.showNotifications": true,
"mockforge.inlinePreview.enabled": true
}
Settings:
mockforge.serverUrl: MockForge server URL (default:http://localhost:3000)mockforge.autoConnect: Automatically connect on startup (default:true)mockforge.showNotifications: Show notifications for mock changes (default:true)mockforge.inlinePreview.enabled: Enable inline preview of mock responses (default:true)
Features
Peek Mock Response
Hover over API endpoint references in your code to see mock responses inline.
Supported Patterns:
fetch('/api/users')axios.get('/api/products')http.get('/api/orders')- Endpoint paths in
mockforge.yamlfiles
Usage:
- Hover over any API endpoint reference in your code
- See the mock response (headers and body) in a tooltip
- Click “Open in Playground” to test the endpoint interactively
Example:
// Hover over this endpoint to see the mock response
const response = await fetch('/api/users');
The hover tooltip will show:
- Response headers
- Response body (formatted JSON)
- Link to open in MockForge Playground
Config Validation
Get real-time validation for your mockforge.yaml files with inline error reporting.
Features:
- Inline error reporting with accurate line/column positions
- Validates against JSON Schema generated from MockForge config types
- Supports multiple config types:
- Main config (
mockforge.yaml) - Reality config (
reality/*.yaml) - Persona config (
personas/*.yaml) - Blueprint config (
blueprint.yaml)
- Main config (
- Auto-detects schema type based on file name and location
- Helpful error messages for:
- Missing required fields
- Type mismatches
- Invalid enum values
- Format errors (email, uri, etc.)
- Pattern mismatches
Example:
# mockforge.yaml
reality:
level: invalid_level # ❌ Error: Invalid reality level
The extension will show an inline error:
Invalid reality level: invalid_level. Valid values: static, light, moderate, high, chaos
Mocks Explorer
Visual tree view of all your mocks with real-time WebSocket updates.
Features:
- Browse all mocks in a tree view
- Color-coded by HTTP method (GET, POST, PUT, DELETE, etc.)
- Real-time updates when mocks change
- Context menu actions:
- Edit Mock
- Delete Mock
- Toggle Mock (enable/disable)
- View Details
Usage:
- Open the MockForge sidebar (click the MockForge icon in the activity bar)
- Browse your mocks in the “Mocks Explorer” view
- Click on a mock to see details
- Right-click for context menu actions
Server Control
Monitor your MockForge server status and statistics.
Features:
- Connection status indicator
- Server version and port
- Uptime and request count
- Active mocks count
- Quick actions to start/stop/restart server
Usage:
- Open the “Server Control” panel in the MockForge sidebar
- View server statistics
- Use quick actions to manage the server
Playground Integration
Quick access to MockForge Playground from hover tooltips.
Usage:
- Hover over an API endpoint reference
- Click “Open in Playground” in the tooltip
- The MockForge Admin UI playground opens in your browser
- The endpoint method and path are pre-filled
Workflow Integration
Development Workflow
- Start MockForge server:
mockforge serve --admin - Open VS Code: The extension auto-connects
- Edit config files: Get real-time validation
- Hover over endpoints: See mock responses inline
- Test in Playground: Click “Open in Playground” from hover tooltips
Config Validation Workflow
- Edit
mockforge.yaml: Start typing your configuration - See inline errors: Validation happens in real-time
- Fix errors: Follow the error messages to correct issues
- Generate schemas (optional): Run
mockforge schema generateto create local schemas
Mock Management Workflow
- View mocks: Open Mocks Explorer
- Create mock: Click “+” icon or use command palette
- Edit mock: Right-click → Edit Mock
- Test mock: Hover over endpoint reference to see response
- Open in Playground: Click link in hover tooltip
Troubleshooting
Extension Not Connecting
- Check that MockForge server is running
- Verify
mockforge.serverUrlsetting is correct - Check VS Code output panel for connection errors
- Try restarting the extension: Command Palette → “MockForge: Restart Extension”
Validation Not Working
- Ensure you have a
mockforge.yamlfile open - Check that schemas are available:
- Look for
schemas/directory in workspace - Or run
mockforge schema generateto create schemas
- Look for
- Check VS Code output panel for validation errors
Hover Preview Not Showing
- Ensure
mockforge.inlinePreview.enabledistrue - Check that MockForge server is connected
- Verify the endpoint path matches a configured mock
- Try hovering over different endpoint patterns