Extends Helper
REST helper allows to send additional requests to the REST API during acceptance tests. Axios (opens new window) library is used to perform requests.
{ helpers: { REST: { endpoint: 'http://site.com/api', onRequest: (request) => { request.headers.auth = '123'; } } }
Send REST requests by accessing _executeRequest
method:
this.helpers['REST']._executeRequest({ url, data, });
config
Executes axios request
request
any
Generates url based on format sent (takes endpoint + url if latter lacks 'http')
url
any
Sends DELETE request to API.
I.sendDeleteRequest('/api/users/1');
url
any
headers
object (opens new window) the headers object to be sent. By default it is sent as an empty objectSend GET request to REST API
I.sendGetRequest('/api/users.json');
url
any
headers
object (opens new window) the headers object to be sent. By default it is sent as an empty objectSends PATCH request to API.
I.sendPatchRequest('/api/users.json', { "email": "[email protected]" });
url
string (opens new window)
payload
any the payload to be sent. By default it is sent as an empty objectheaders
object (opens new window) the headers object to be sent. By default it is sent as an empty objectSends POST request to API.
I.sendPostRequest('/api/users.json', { "email": "[email protected]" });
url
any
payload
any the payload to be sent. By default it is sent as an empty objectheaders
object (opens new window) the headers object to be sent. By default it is sent as an empty objectSends PUT request to API.
I.sendPutRequest('/api/users.json', { "email": "[email protected]" });
url
string (opens new window)
payload
any the payload to be sent. By default it is sent as an empty objectheaders
object (opens new window) the headers object to be sent. By default it is sent as an empty objectSet timeout for the request
I.setRequestTimeout(10000); // In milliseconds
newTimeout
© 2015 DavertMik <[email protected]> (http://codegyre.com)
Licensed under the MIT License.
https://codecept.io/helpers/REST/