JavaScript
Last updated
Last updated
Moropo uses Maestro's GraalJS engine to execute JavaScript steps inside your tests.
This provides a similar JavaScript environment to NodeJS.
Note: it's not currently possible to import node_modules
Add or upload a script directly from the Test Editor
Use the runScript command to call a script during a test run.
output
is a special JavaScript object which is shared by each test run and can be used to store variables for use in your tests.
For example, I could set output.name
inside my JavaScript file called get name:
In my test, I can then access this by calling runScript
and then using ${}
to access the variable.
For example:
IMPORTANT NOTE Moropo does not currently persist JavaScript data between 'plays' in the Test Editor If a step requires a data set by JS, you must also select the dependent step when playing that step.
For example, in the below case step 3 requires a variable set by step 2. Every time I wish to play step 3, I must also select step 2.
You can make HTTP requests using the built-in library.
For example, to make a simple GET request, filter the data, and save it to a variable:
http.get("https://myendpoint.com")
http.post("https://myendpoint.com")
http.put("https://myendpoint.com")
http.delete("https://myendpoint.com")
Headers can be passed using the headers
parameter
Use the json()
built-in helper function to parse JSON responses.