JavaScript

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

Creating a script

Add or upload a script directly from the Test Editor

Execute a script

Use the runScript command to call a script during a test run.

Using Variables

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:

Making HTTP Requests

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 request methods

  • http.get("https://myendpoint.com")

  • http.post("https://myendpoint.com")

  • http.put("https://myendpoint.com")

  • http.delete("https://myendpoint.com")

Headers

Headers can be passed using the headers parameter

JSON parsing

Use the json() built-in helper function to parse JSON responses.

Last updated

Was this helpful?