Skip to content

Create a simple static mock

Sran Manpreet edited this page Aug 23, 2023 · 1 revision

In this section, you'll learn how to craft the simplest type of mock, known as the static mock.

Initiate the process by clicking the "New mock" button located in the navigation bar. Fill in the fields as illustrated in the image below:

Filled Mock Form

Pay attention to the specified path /books and the request method get. This mock will be served in response to get requests on http://localhost:8080/books. (Assuming Mockpit-server is running on port 8080)

In the Response Body Type field, select Static, and input the content for the Response Body Content field, following the example in the screenshot.

Set the Content type to application/json.

For additional headers, click the plus (+) icon beside Response Headers:

Blank Headers

Once configured, save the mock. Proceed to http://localhost:8080/books to view the result.

In the example provided below, observe the Postman console. The Response Body Content you set in the mock is evident:

Headers

Furthermore, the header Library that you defined can be observed in the Response Headers:

Headers Response

This guide facilitates the creation of static mocks, allowing you to promptly set up consistent mock responses for your endpoints.

Next: Create a dynamic mock with JavaScript

Clone this wiki locally