You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -99,6 +100,7 @@ Following is a sample `responses.json` file:
99
100
},
100
101
{
101
102
"url": "/v1.0/me/photo",
103
+
"method": "GET",
102
104
"responseCode": 404
103
105
}
104
106
]
@@ -110,13 +112,14 @@ The file defines an `responses` property with an array of responses. Each respon
110
112
Property|Description|Required|Default value|Sample value
111
113
--|--|:--:|--|--
112
114
`url`|Server-relative URL to a Microsoft Graph API to respond to|yes||`/v1.0/me`
115
+
`method`|Http verb used to match request in conjuction with `url`|yes||`GET`
113
116
`responseBody`|Body to send as the response to the request|no|_empty_|See above
114
117
`responseCode`|Response status code|no|`200`|`404`
115
118
`responseHeaders`|Collection of headers to include in the response|no|_empty_|See above
116
119
117
120
#### Mock responses order
118
121
119
-
Mocks are matched in the order in which they are defined in the `responses.json` file, first matching response taking precedence over others. If you'd define multiple responses with the same URL, the first response would be used.
122
+
Mocks are matched in the order in which they are defined in the `responses.json` file, first matching response taking precedence over others. If you'd define multiple responses with the same URL and method, the first matching response would be used.
120
123
121
124
For a configuration file like:
122
125
@@ -125,17 +128,19 @@ For a configuration file like:
125
128
"responses": [
126
129
{
127
130
"url": "/v1.0/me/photo",
131
+
"method": "GET",
128
132
"responseCode": 500
129
133
},
130
134
{
131
135
"url": "/v1.0/me/photo",
136
+
"method": "GET",
132
137
"responseCode": 404
133
138
}
134
139
]
135
140
}
136
141
```
137
142
138
-
all requests to `/v1.0/me/photo` would respond with `500 Internal Server Error`.
143
+
all `GET`requests to `/v1.0/me/photo` would respond with `500 Internal Server Error`.
139
144
140
145
> **Important**
141
146
>
@@ -150,6 +155,7 @@ When defining mock responses, you can define a specific URL to mock, but also a
If a URL of a mock response contains an `*`, it's used as a regular expression, where each `*` is converted into a `.*`, basically matching any sequence of characters. This is important to keep in mind, because if a pattern is too broad and defined before more specific mocks, it could unintetionally return unexpected responses, for example:
177
183
@@ -180,6 +186,7 @@ If a URL of a mock response contains an `*`, it's used as a regular expression,
@@ -220,13 +228,14 @@ If a URL of a mock response contains an `*`, it's used as a regular expression,
220
228
}
221
229
```
222
230
223
-
for request `/v1.0/users/48d31887-5fad-4d73-a9f5-3c356e68a038`, the proxy would return `Adele Vance` instead of `Megan Bowen`, because the asterisk at the end matches any series of characters. The correct way to define these responses, would be to change their order in the array:
231
+
for request `GET /v1.0/users/48d31887-5fad-4d73-a9f5-3c356e68a038`, the proxy would return `Adele Vance` instead of `Megan Bowen`, because the asterisk at the end matches any series of characters. The correct way to define these responses, would be to change their order in the array:
0 commit comments