Request
Request matching
Mock JSON Response supports matching of requests to stub using the following attributes
URL
HTTP Method
Headers
Here is an example:
method and urlPath are mandatory for request matching.
URL Path
This is the path of the requested URL. This field will accept both the string and regex as value.
The above URL path will be matched with http://localhost:3000/list/shopping/items
Method
Request method such as GET, POST, PUT, PATCH, DELETE and others will be matched with the help of this attribute.
Headers
Headers is an object that holds the header, helper and the value of the header to be matched together. Helpers supported in Mock JSON Response are "equalTo", "matches", "contains". As the name suggests these helper match when URL is an exact match, when the regex is a match and contains in the incoming request.
Above example matches to a request: GET http://localhost:3000/mock/list with x-route: "items-list" as headers.
If a request has multiple matches, a warning message, with the possible stub name will be received.
Other possible fields of the request will be explained in later sections.
Last updated
Was this helpful?