Platform
Executing JavaScript
Executing arbitrary JavaScript as part of Momentic tests
You can execute JavaScript in two ways on the Momentic platform:
- 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.
{{}}
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.
- You do not need to include a
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 serversassert
: Execute assertions based on other variables and constantsfaker
: Generate mock data easilymoment
: Create and manipulateDate
objects
Was this page helpful?