/interactive-mock-server

Mock server that allows changing mock endpoints dynamically!

Primary LanguageJavaScriptMIT LicenseMIT

Interactive Mock Server

An mock server that allows you to dynamically adjust mock endpoints in real-time!

Install and Run

Install the mock server globally and run it:

# Install using yarn:
$ yarn global add interactive-mock-server
# Install using npm:
$ npm install --global interactive-mock-server
# Now use it!
$ interactive-mock-server

You can also install it locally:

# Install using yarn:
$ yarn add interactive-mock-server --dev
# Install using npm:
$ npm install --save-dev interactive-mock-server
# Now use it!
$ yarn interactive-mock-server
$ npx interactive-mock-server

Once started, navigate to localhost:9000/__dashboard (see more info on the dashboard)

Overview

Almost all mock server implementations provide the option to specify mock routes/endpoints beforehande, but they don't allow you to dynamically adjust those routes after a certain amount of time. While those implementations are geared toward CI environment testing, manual testing of you app is also important.

Exploring Different Responses

How your app responds to different responses requires a type of exploration that other mock servers don't have. The ability to adjust a route's response dynamically allows you to test how the app responds to different responses from the same route over time. This also allows you to explore how the app responds to unexpected responses without having to copy boilerplate code, adjust one small part (such as the the status code) and restart the server.

Instead this mock server provides an interactive way of adjusting simple parts of the mocked response without having to stop and start the mock server over and over.

Using the dashboard

Once the server is started (see instructions running), You can navigate to the dashboard page /__dashboard. This route exists as a way to prevent conflicts with other potential mock endpoints. From this page, you can view endpoints (/__dashboard/endpoints), create a new endpoint (/__dashboard/endpoints/new) or view/edit an existing endpoint (/__dashboard/endpoints/:id).

Once an endpoint has been created, it will be automatically enabled on the mock server.

Contributing

If you have a bug/feature request head over to the issues page. All Issues and PRs are welcome!

Debugging

  1. Clone the project
  2. Install dependencies: yarn install
  3. Build the frontend: yarn run build
  4. Launch the server: yarn run dev:app
  5. Navigate to the dashboard: (default is http://localhost:9000/__dashboard)

Created mock endpoints are available from the same base: http://localhost:9000/

Debugging the frontend

Repeat steps 1-4 above and

  1. Launch the webpack dev server: yarn run dev:web
  2. Navigate to the development dashboard: (default is http://localhost:9100/__dashboard)

NOTE: The mock server must also be running in a separate terminal (Step 4). The dashboard uses several API methods from the mock server that are automatically proxied to the mock server.

ALSO NOTE: All created mock endpoints will be available using the mock server, NOT the webpack dev server. You will have to go to http://localhost:9000 instead of http://localhost:9100 to test the mock endpoints created