Skip to main content

Documentation Index

Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

The simplified form takes a single string of JavaScript. Use code for multi-line scripts. Variables on env are available without templating: env.MY_VAR rather than {{ env.MY_VAR }}.

Parameters

ParameterTypeRequiredDescription
codestringYesJavaScript source.
environment"node" | "browser"NoWhere to run the script. Defaults to node.
fragmentbooleanNoTreat code as a fragment (no implicit return).
timeoutnumberNoMaximum time in milliseconds.
saveAsstringNoName of the variable to write this step’s return value to.
retriesnumberNoNumber of times to retry the step on failure before failing the test.
skippedbooleanNoSkip this step at execution time.
commentstringNoFree-form annotation kept with the step.

Shorthand

JavaScript expression as a single string. env.NAME refers to a variable directly — do not wrap it in {{ }}.
- javascript: setVariable('USERNAME', 'testuser')

Examples

- javascript:
    code: return faker.person.fullName()
    saveAs: NAME
- javascript:
    code: return `random-module-name-${Date.now()}`
    saveAs: MODULE_NAME
- javascript:
    code: |-
      assert(env.TODOS.length === 3)
      for (const todo of env.TODOS) {
        assert("request" in todo)
        assert("response" in todo)
      }
- javascript:
    code: |-
      const permission = await navigator.permissions.query({ name: 'camera' })
      if (permission.state !== "granted") {
        throw new Error(`Expected camera permission, got ${permission.state}`)
      }
    environment: browser