-
Notifications
You must be signed in to change notification settings - Fork 1
Create a simple static mock
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:
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
:
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:
Furthermore, the header Library that you defined can be observed in the Response Headers
:
This guide facilitates the creation of static mocks, allowing you to promptly set up consistent mock responses for your endpoints.