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.

# Configuration

  • endpoint: API base URL
  • timeout: timeout for requests in milliseconds. 10000ms by default
  • defaultHeaders: a list of default headers
  • onRequest: a async function which can update request object.
  • maxUploadFileSize: set the max content file size in MB when performing api calls.

# Example

  helpers: {
    REST: {
      endpoint: '',
      onRequest: (request) => {
      request.headers.auth = '123';

# Access From Helpers

Send REST requests by accessing _executeRequest method:


# Methods

# Parameters

  • config

# _executeRequest

Executes axios request

# Parameters

  • request any

# _url

Generates url based on format sent (takes endpoint + url if latter lacks 'http')

# Parameters

  • url any

# sendDeleteRequest

Sends DELETE request to API.


# Parameters

# sendGetRequest

Send GET request to REST API


# Parameters

# sendPatchRequest

Sends PATCH request to API.

I.sendPatchRequest('/api/users.json', { "email": "[email protected]" });

// To mask the payload in logs
I.sendPatchRequest('/api/users.json', secret({ "email": "[email protected]" }));

# Parameters

# sendPostRequest

Sends POST request to API.

I.sendPostRequest('/api/users.json', { "email": "[email protected]" });

// To mask the payload in logs
I.sendPostRequest('/api/users.json', secret({ "email": "[email protected]" }));

# Parameters

  • url any
  • payload any the payload to be sent. By default it is sent as an empty object
  • headers object (opens new window) the headers object to be sent. By default it is sent as an empty object

# sendPutRequest

Sends PUT request to API.

I.sendPutRequest('/api/users.json', { "email": "[email protected]" });

// To mask the payload in logs
I.sendPutRequest('/api/users.json', secret({ "email": "[email protected]" }));

# Parameters

# setRequestTimeout

Set timeout for the request

I.setRequestTimeout(10000); // In milliseconds

# Parameters

  • newTimeout
Last Updated: 2/5/2021, 2:49:41 AM