browser-mock

Logo

View the Project on GitHub wesflo/browser-mock

MockProxy - A Developer’s HTTP Request Interception Tool

MockProxy is a lightweight browser extension designed to simplify API testing and local development. Effortlessly intercept HTTP requests, redirect them to your local Node.js server, and respond with pre-configured mock data.

Features

Core Features

Other Features


  1. Load the Extension in Chrome:
    • Open Chrome and navigate to chrome://extensions/.
    • Enable “Developer mode” (toggle in the top right).
    • Click “Load unpacked” and select the mockproxy directory.
  2. Configure the Plugin:
    • Update the manifest.json file in the extension directory with your project settings (see Configuration).

Usage

  1. Open the popup menu by clicking on the MockProxy icon in the browser toolbar.
  2. Select a project or individual requests to activate.
  3. Set desired response status codes and timeouts.
  4. Start testing your APIs with local mock responses.

Configuration

The plugin uses a file to define projects, domains, and requests. Here’s an example configuration:

{
  "domains": [
    "https://api.dev.example.com",
    "https://api.preprod.example.com",
    "https://api.example.com"
  ],
  "requests": [
    {
      "name": "Get Dummy Data",
      "url": "/api/v1/health",
      "method": "GET",
      "response": {
        "200": "./health.json",
        "204": "",
        "400": "./badRequest.json"
      }
    },
    {
      "name": "Post Dummy Data",
      "url": "/api/v2/foo/[\\d]{5,10}",
      "method": "POST",
      "response": {
        "200": "../mock/health-post.json",
        "400": "./badRequest.json"
      }
    },
    {
      "name": "Put Dummy Data",
      "url": "/api/v1/return/[\\d]{4,10}/[\\d]{2,10}",
      "method": "PUT",
      "response": {
        "200": "../mock/health-put.json",
        "400": "./badRequest.json"
      }
    }
  ]
}

Permissions

MockProxy requires the following permissions to function:

Contributing

We welcome contributions! To get started:

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a Pull Request.

Roadmap

License

This project is licensed under the MIT License.

Feedback and Support

If you encounter any issues or have feature suggestions, feel free to open an issue or join the discussion here: https://github.com/wesflo/browser-mock/discussions.

Acknowledgments

Special thanks to the open-source community for providing tools and inspiration for this project.