> ## 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.

# javascript

> Run a JavaScript snippet during the test.

Runs a JavaScript snippet. The return value can be stored with `saveAs`. The
simplified form takes the code as a single string.

## Parameters

| Parameter | Type      | Required | Description                                                 |
| --------- | --------- | -------- | ----------------------------------------------------------- |
| `code`    | `string`  | Yes      | JavaScript to run.                                          |
| `timeout` | `number`  | No       | Execution timeout in milliseconds.                          |
| `saveAs`  | `string`  | No       | Variable to store this step's return value on `env.<name>`. |
| `retries` | `number`  | No       | Times to retry the step on failure before failing the test. |
| `skipped` | `boolean` | No       | Skip this step at execution time.                           |

## Shorthand

Code as a single string.

```yaml theme={null}
- javascript: "return env.COUNT + 1"
```

## Examples

```yaml theme={null}
- javascript:
    code: "return Date.now()"
    saveAs: NOW # return value is available as {{ env.NOW }}
```

## Related

* [Test format](/core-concepts/test-format)
* [JavaScript integration](/integrations/javascript)
