Skip to content
| Marketplace
Sign in
Visual Studio Code>Testing>Mock Server ExtensionNew to Visual Studio Code? Get it now.
Mock Server Extension

Mock Server Extension

Uttam Gupta

|
2 installs
| (0) | Free
Running local mock server from JSON config
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Mock Server Extension

A VS Code extension to run a local mock server with support for dynamic responses using Faker.js.

Features

  • Start/Stop Server: Run a local mock server directly from VS Code.
  • Configurable Routes: Define routes in a JSON configuration.
  • Dynamic Responses: Generate mock data on the fly using Faker.js.
  • Static Responses: Serve fixed JSON responses.
  • Delays: Simulate network latency.

Configuration

The mock server accepts a JSON configuration object.

Example mock-server.json

{
  "routes": [
    {
      "method": "GET",
      "path": "/api/users",
      "status": 200,
      "dynamic": true,
      "response": [
        {
          "id": "faker.string.uuid",
          "name": "faker.person.fullName",
          "email": "faker.internet.email"
        }
      ]
    },
    {
      "method": "POST",
      "path": "/api/login",
      "status": 200,
      "response": {
        "token": "static-token"
      }
    }
  ]
}

Route Options

| Property | Type | Description | |Data Type|Type|Description| |---|---|---| | method | string | HTTP method (GET, POST, etc.) | | path | string | URL path (e.g., /api/users) | | status | number | HTTP status code (e.g., 200, 404) | | delay | number | Response delay in milliseconds | | dynamic | boolean | If true, responses are generated on every request. If false (default), they are generated once on startup. | | response | any | The JSON response body. Use strings starting with faker. to invoke Faker.js methods. |

Dynamic Responses with Faker.js

You can use any method from Faker.js by using a string path starting with faker..

Examples:

  • "faker.person.firstName" -> "John"
  • "faker.internet.email" -> "john@example.com"
  • "faker.date.recent" -> "2023-10-05T14:48:00.000Z"

Nested objects and arrays are fully supported.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft