-
Notifications
You must be signed in to change notification settings - Fork 1
Using Mock Form
One of the pivotal pages within Mockpit is the Mock Form, which plays a central role in configuring mock endpoints.
To access the Mock Form, proceed to the Mockpit homepage and click the New Mock
button:
Upon clicking, you'll land on the Mock Form page:
Assign a distinctive name to your mock. While this doesn't impact mock behavior, it aids in locating the mock on the "Manage Mocks" page.
Provide a descriptive summary for the mock's purpose. Though it doesn't influence mock behavior, including details here assists both you and your colleagues in comprehending the mock's intent.
It allows users to temporarily disable a mock API without deleting it, ensuring precise control over mock availability for testing and development.
Specify the HTTP method for which the mock's endpoint will respond.
Define the endpoint of the mock by providing a relative path, such as /books.
As you input the relative path, the Route Preview displays the complete endpoint path, incorporating the backend URL prefix.
Set the desired response status code, such as 200 for OK or 400 for Bad Request.
Choose from two options:
-
Static: The content entered in the
Response Body Content
field will be the response body as-is. -
Javascript: The content in the
Response Body Content
field will be treated as JavaScript code and the script's result will be the response's body.
Defines the content type header of the response, a.k.a. the media type of the resource.
This field contains the response's content. Depending on the response body type chosen, the content will either be served statically or dynamically evaluated.
[{"name": "Design Patterns in Java"},{"name": "Data Structures and Algorithms by Cormen"}]
Learn more about creating a simple static mock.
return JSON.stringify({ date : new Date()});
Explore creating a dynamic mock with javascript.
Click on plus (+
) icon to add a new response header.
Specify the name of the header.
Input the value of the header.
This comprehensive guide simplifies the process of setting up mock configurations using Mockpit's Mock Form.
Next: Manage mocks