@@ -14,25 +14,21 @@ title: REST
1414REST helper allows to send additional requests to the REST API during acceptance tests.
1515[ Axios] [ 1 ] library is used to perform requests.
1616
17-
18-
1917## Configuration
2018
2119Type: [ object] [ 4 ]
2220
2321### Properties
2422
25- * ` endpoint ` ** [ string] [ 3 ] ?** API base URL
26- * ` prettyPrintJson ` ** [ boolean] [ 6 ] ?** pretty print json for response/request on console logs.
27- * ` printCurl ` ** [ boolean] [ 6 ] ?** print cURL request on console logs. False by default.
28- * ` timeout ` ** [ number] [ 5 ] ?** timeout for requests in milliseconds. 10000ms by default.
29- * ` defaultHeaders ` ** [ object] [ 4 ] ?** a list of default headers.
30- * ` httpAgent ` ** [ object] [ 4 ] ?** create an agent with SSL certificate
31- * ` onRequest ` ** [ function] [ 7 ] ?** an async function which can update request object.
32- * ` onResponse ` ** [ function] [ 7 ] ?** an async function which can update response object.
33- * ` maxUploadFileSize ` ** [ number] [ 5 ] ?** set the max content file size in MB when performing api calls.
34-
35-
23+ - ` endpoint ` ** [ string] [ 3 ] ?** API base URL
24+ - ` prettyPrintJson ` ** [ boolean] [ 6 ] ?** pretty print json for response/request on console logs.
25+ - ` printCurl ` ** [ boolean] [ 6 ] ?** print cURL request on console logs. False by default.
26+ - ` timeout ` ** [ number] [ 5 ] ?** timeout for requests in milliseconds. 10000ms by default.
27+ - ` defaultHeaders ` ** [ object] [ 4 ] ?** a list of default headers.
28+ - ` httpAgent ` ** [ object] [ 4 ] ?** create an agent with SSL certificate
29+ - ` onRequest ` ** [ function] [ 7 ] ?** an async function which can update request object.
30+ - ` onResponse ` ** [ function] [ 7 ] ?** an async function which can update response object.
31+ - ` maxUploadFileSize ` ** [ number] [ 5 ] ?** set the max content file size in MB when performing api calls.
3632
3733## Example
3834
@@ -91,34 +87,34 @@ Send REST requests by accessing `_executeRequest` method:
9187
9288``` js
9389this .helpers [' REST' ]._executeRequest ({
94- url,
95- data,
96- });
90+ url,
91+ data,
92+ })
9793```
9894
9995## Methods
10096
10197### Parameters
10298
103- * ` config `   ;
99+ - ` config `   ;
104100
105- ### _ executeRequest
101+ ### \ _ executeRequest
106102
107103Executes axios request
108104
109105#### Parameters
110106
111- * ` request ` ** any**   ;
107+ - ` request ` ** any**   ;
112108
113109Returns ** [ Promise] [ 2 ] <any >** response
114110
115- ### _ url
111+ ### \ _ url
116112
117113Generates url based on format sent (takes endpoint + url if latter lacks 'http')
118114
119115#### Parameters
120116
121- * ` url ` ** any**   ;
117+ - ` url ` ** any**   ;
122118
123119### amBearerAuthenticated
124120
@@ -131,28 +127,28 @@ I.amBearerAuthenticated(secret('heregoestoken'))
131127
132128#### Parameters
133129
134- * ` accessToken ` ** ([ string] [ 3 ] | CodeceptJS.Secret)** Bearer access token
130+ - ` accessToken ` ** ([ string] [ 3 ] | CodeceptJS.Secret)** Bearer access token
135131
136132### haveRequestHeaders
137133
138134Sets request headers for all requests of this test
139135
140136#### Parameters
141137
142- * ` headers ` ** [ object] [ 4 ] ** headers list
138+ - ` headers ` ** [ object] [ 4 ] ** headers list
143139
144140### sendDeleteRequest
145141
146142Sends DELETE request to API.
147143
148144``` js
149- I .sendDeleteRequest (' /api/users/1' );
145+ I .sendDeleteRequest (' /api/users/1' )
150146```
151147
152148#### Parameters
153149
154- * ` url ` ** any**   ;
155- * ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
150+ - ` url ` ** any**   ;
151+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
156152
157153Returns ** [ Promise] [ 2 ] <any >** response
158154
@@ -161,14 +157,14 @@ Returns **[Promise][2]<any>** response
161157Sends DELETE request to API with payload.
162158
163159``` js
164- I .sendDeleteRequestWithPayload (' /api/users/1' , { author: ' john' });
160+ I .sendDeleteRequestWithPayload (' /api/users/1' , { author: ' john' })
165161```
166162
167163#### Parameters
168164
169- * ` url ` ** any**   ;
170- * ` payload ` ** any** the payload to be sent. By default it is sent as an empty object
171- * ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
165+ - ` url ` ** any**   ;
166+ - ` payload ` ** any** the payload to be sent. By default it is sent as an empty object
167+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
172168
173169Returns ** [ Promise] [ 2 ] <any >** response
174170
@@ -177,13 +173,28 @@ Returns **[Promise][2]<any>** response
177173Send GET request to REST API
178174
179175``` js
180- I .sendGetRequest (' /api/users.json' );
176+ I .sendGetRequest (' /api/users.json' )
181177```
182178
183179#### Parameters
184180
185- * ` url ` ** any**   ;
186- * ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
181+ - ` url ` ** any**   ;
182+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
183+
184+ Returns ** [ Promise] [ 2 ] <any >** response
185+
186+ ### sendHeadRequest
187+
188+ Send HEAD request to REST API
189+
190+ ``` js
191+ I .sendHeadRequest (' /api/users.json' )
192+ ```
193+
194+ #### Parameters
195+
196+ - ` url ` ** any**   ;
197+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
187198
188199Returns ** [ Promise] [ 2 ] <any >** response
189200
@@ -192,18 +203,17 @@ Returns **[Promise][2]<any>** response
192203Sends PATCH request to API.
193204
194205``` js
195- I .
sendPatchRequest (
' /api/users.json' , {
" email" : " [email protected] " })
; 206+ I .
sendPatchRequest (
' /api/users.json' , { email
: ' [email protected] ' })
196207
197208// To mask the payload in logs
198- I .
sendPatchRequest (
' /api/users.json' ,
secret ({
" email" : " [email protected] " }));
199-
209+ I .
sendPatchRequest (
' /api/users.json' ,
secret ({ email
: ' [email protected] ' }))
200210```
201211
202212#### Parameters
203213
204- * ` url ` ** [ string] [ 3 ] **   ;
205- * ` payload ` ** any** the payload to be sent. By default it is sent as an empty object
206- * ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default it is sent as an empty object
214+ - ` url ` ** [ string] [ 3 ] **   ;
215+ - ` payload ` ** any** the payload to be sent. By default it is sent as an empty object
216+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default it is sent as an empty object
207217
208218Returns ** [ Promise] [ 2 ] <any >** response
209219
@@ -212,18 +222,17 @@ Returns **[Promise][2]<any>** response
212222Sends POST request to API.
213223
214224``` js
215- I .
sendPostRequest (
' /api/users.json' , {
" email" : " [email protected] " })
; 225+ I .
sendPostRequest (
' /api/users.json' , { email
: ' [email protected] ' })
216226
217227// To mask the payload in logs
218- I .
sendPostRequest (
' /api/users.json' ,
secret ({
" email" : " [email protected] " }));
219-
228+ I .
sendPostRequest (
' /api/users.json' ,
secret ({ email
: ' [email protected] ' }))
220229```
221230
222231#### Parameters
223232
224- * ` url ` ** any**   ;
225- * ` payload ` ** any** the payload to be sent. By default, it is sent as an empty object
226- * ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
233+ - ` url ` ** any**   ;
234+ - ` payload ` ** any** the payload to be sent. By default, it is sent as an empty object
235+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default, it is sent as an empty object
227236
228237Returns ** [ Promise] [ 2 ] <any >** response
229238
@@ -232,18 +241,17 @@ Returns **[Promise][2]<any>** response
232241Sends PUT request to API.
233242
234243``` js
235- I .
sendPutRequest (
' /api/users.json' , {
" email" : " [email protected] " })
; 244+ I .
sendPutRequest (
' /api/users.json' , { email
: ' [email protected] ' })
236245
237246// To mask the payload in logs
238- I .
sendPutRequest (
' /api/users.json' ,
secret ({
" email" : " [email protected] " }));
239-
247+ I .
sendPutRequest (
' /api/users.json' ,
secret ({ email
: ' [email protected] ' }))
240248```
241249
242250#### Parameters
243251
244- * ` url ` ** [ string] [ 3 ] **   ;
245- * ` payload ` ** any** the payload to be sent. By default it is sent as an empty object
246- * ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default it is sent as an empty object
252+ - ` url ` ** [ string] [ 3 ] **   ;
253+ - ` payload ` ** any** the payload to be sent. By default it is sent as an empty object
254+ - ` headers ` ** [ object] [ 4 ] ** the headers object to be sent. By default it is sent as an empty object
247255
248256Returns ** [ Promise] [ 2 ] <any >** response
249257
@@ -252,23 +260,17 @@ Returns **[Promise][2]<any>** response
252260Set timeout for the request
253261
254262``` js
255- I .setRequestTimeout (10000 ); // In milliseconds
263+ I .setRequestTimeout (10000 ) // In milliseconds
256264```
257265
258266#### Parameters
259267
260- * ` newTimeout ` ** [ number] [ 5 ] ** timeout in milliseconds
268+ - ` newTimeout ` ** [ number] [ 5 ] ** timeout in milliseconds
261269
262270[ 1 ] : https://github.com/axios/axios
263-
264271[ 2 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
265-
266272[ 3 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
267-
268273[ 4 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
269-
270274[ 5 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
271-
272275[ 6 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
273-
274276[ 7 ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
0 commit comments