You can execute JavaScript in two ways on the Momentic platform:

  1. JavaScript step: this is a special step that allows you execute a block of JavaScript code.
    • The returned value is the result of the JavaScript step.
  2. {{}} expressions: String fields in all steps can contain JavaScript expressions inside curly brackets. For example, the value of a Type step can be {{ env.USERNAME }}@gmail.com .
    • You do not need to include a return statement.
    • The expression inside the curly braces must be a single line. If you need multiple lines, use the JavaScript step.

Global Libraries

In addition to the built-in libraries provided by Node.js, the following external libraries are available to you in JavaScript steps and {{}} expressions:

  • axios: Send HTTP/HTTPS requests to other servers
  • assert: Execute assertions based on other variables and constants
  • faker: Generate mock data easily
  • moment: Create and manipulate Date objects