With functional testing you can easily test your backend functions individually, reducing the need to build your own system for triggering and testing your backend code.
You can use functional testing to test a variety of scenarios, such as functions with:
Here is an example of a function with an HTTP request that performs basic arithmetic operations based on the request path and query parameters:
To test HTTP functions with functional testing, specify the HTTP request object in the Set Parameters section. A request template is initially created for you with placeholder data, but you need to edit it to fit your specific needs.
For example, when testing a post
function, replace the placeholder JSON object in the body
property with a JSON object you want to test with.
The following properties are included in the request templates:
get
and delete
functions: path
, headers
, and query
put
and post
functions: path
, headers
, and body
options
functions: path
and headers
use
functions: path
, headers
, query
, and method
Destructuring allows you to extract values from arrays or properties from objects into distinct variables. Here is an example of a function that destructures the parameters { factor1, factor2 }
directly from the passed object and returns their product:
To test a function with destructured parameters, place parameter values in a JSON object inside an array:
When you set default values in your function declarations, you can test those functions without needing to provide all of the arguments. Here is an example of a function that uses default values for factor2
and factor3
.
To test a function without providing all of the arguments, place the arguments in an array in the Set Parameters section, and leave out at least one of the arguments that has a default value.
For example, the multiplyWithDefaults()
function above was tested three times with the following arguments:
The following results were returned:
The JavaScript arguments object can accept any number of arguments in a function. Here is an example of a function that uses the arguments object to find the sum of all the arguments provided.
To test a function containing the JavaScript arguments object, place the arguments in an array in the Set Parameters section:
Here is an example of a function that takes a Date object as the parameter:
To test a function with a parameter of type Date, you need to use a stringified date in the JSON object. You can use one of the following syntaxes: