Skip to main content
JavaScript steps execute code as part of a test. async/await is supported. Return values are passed to downstream steps and must be JSON-serializable.

Execution contexts

Browser steps don’t have access to the Node sandbox globals.

Timeout

JavaScript steps default to a 90 second timeout. Configure per step via the Timeout field, or in YAML (value is in seconds):
The maximum configurable timeout is 10 minutes (600 seconds), suitable for long external polls or batched lookups against slow APIs. If a nested helper such as email.fetchLatest or sms.fetchLatest polls for longer than the JavaScript step’s own timeout, the step is killed before the helper returns. Set the step’s Timeout to comfortably cover the longest nested poll.

{{ }} templating

Any string input on any step can contain {{ expression }}. Expressions evaluate at runtime and are interpolated into the value.
Don’t use {{}} inside JavaScript step source. Variables are already in scope as env.VARIABLE_NAME.

Momentic utilities

Provided by the Momentic runtime.

env

Read-only map of the current environment’s variables. See Variables for how variables are resolved.

setVariable(name, value)

Write a variable scoped to the current test run. Downstream steps can read it via {{ name }} in any string input, or via env.name inside JavaScript.

email

Send and fetch email. See Email for inbox setup.

sms

Send and fetch SMS. See SMS for number setup.

extractCookiesFromResponse(response)

Convert a fetch / axios response’s Set-Cookie headers into an array of Playwright-compatible cookies. Useful for bootstrapping an authenticated browser context.

mock

Only available in mock handler steps on mocked routes. Exposes the intercepted Request and the upstream Response.

Libraries

axios

HTTP client. See axios docs.

assert

Node’s built-in assertions. See Node docs.

faker

Generate realistic fake data. See Faker docs.

moment

Parse and format dates. See Moment docs.

pg

Postgres client. See node-postgres docs.

OTPAuth

Generate TOTP codes for 2FA tests. See otpauth docs.

child_process

Spawn subprocesses. See Node docs.

Octokit + createAppAuth

Authenticated GitHub API access. See Octokit docs and auth-app docs.