Globals

In addition to the at object, scripts in Atrahasis have a small handful of globals available. The exact set depends on where the script runs. Most places expose the full set, but load test step scripts run in a more restricted environment.

console

A console with four methods for writing to the script output strip at the bottom of the editor:

  • console.log(...args): plain message, no prefix.
  • console.info(...args): prefixed with [INFO].
  • console.warn(...args): prefixed with [WARN].
  • console.error(...args): prefixed with [ERROR].

In main-engine scripts (standalone, project, flow, and lifecycle), objects are pretty-printed via JSON.stringifywith two-space indentation. In load test step scripts (Boa engine), each argument is stringified with JavaScript's default toString, so a plain object shows up as [object Object]. Call JSON.stringify yourself if you need the full value. As noted in the chapter intro, the total console output of a single script run is capped at 1000 characters; past that, further calls are silently dropped (main-engine scripts also append a single "Log limit reached" notice at the cap).

fetch

The fetch(url, options) global is a drop-in replacement for the browser's Fetch API: same signature, same Response shape returned as a Promise, same .json()/ .text() methods. The important difference is that Atrahasis's fetchroutes through the app's own HTTP backend rather than the browser. Practical consequences:

  • CORS does not apply. You can call any HTTPS endpoint (an internal service, a webhook, a Slack bot) without the browser-level cross-origin restrictions.
  • Same settings as the rest of the app. DNS resolution, TLS handling, proxies, and certificate trust follow the same configuration the main HTTP request tab uses.
  • Binary and text bodies are both supported. Pass a string, an ArrayBuffer, a typed array, or any object that is serializable to JSON.

setTimeout

The native setTimeout(fn, ms)is exposed unchanged. Useful for small delays inside a script, for example waiting a few hundred milliseconds between two fetches in a Before All script. Remember that the whole script still has a 30-second budget, so long delays will push you into a timeout.

Top-Level await

Every script body is wrapped in an async function before it runs, so you can write await fetch(...)or await at.export.pdf()directly at the top level, with no need to define your own async wrapper.

Standard JavaScript and WebView Globals

Main-engine scripts run inside the app's WebView, so every standard JavaScript built-in and most browser-surfaced globals are available without extra plumbing:

  • Language built-ins: Math, Date, JSON, Promise, RegExp, Map, Set, Error, and all the usual string / array / number helpers.
  • URL helpers: URL and URLSearchParams.
  • Web Crypto: crypto.randomUUID(), crypto.getRandomValues(), and crypto.subtle for hashing, HMAC, signing, etc.
  • Text encoding: TextEncoder and TextDecoder.
  • Base64: atob and btoa.

Load test step scripts are the exception. They run in a Boa-based runtime that exposes only the JavaScript language built-ins plus console, at, and a cut-down fetch. WebView-sourced globals like crypto, URL, or TextEncoder are notavailable inside a load test step script. See Load Test Step Limits for the full list.

Load Test Step Scripts Are Different

Load test step scripts (Pre-Script and Post-Script on a step inside a load test spec) run in a smaller, sandboxed engine built for running thousands of virtual users in parallel. That engine deliberately keeps its surface small: console, at, and a reduced fetch:

  • A reduced fetch: you can call fetch(url, options) with method, headers, and body, and the call reuses the same connection plumbing as the step's own requests. What comes back is a plain object with status, ok, headers, body, json(), and text(), not a full Response, and the body is always text.
  • No setTimeout: artificial delays are not available.
  • Nothing is genuinely asynchronous: the engine strips await before running the script, so await fetch(...) reads fine and works, but a real Promise is never waited on. fetch itself blocks until the response arrives.

Load test lifecycle scripts (Before All and After All) are not subject to these limits. They run on the full engine, exactly like flow lifecycle scripts. If a step script needs something the small engine does not carry, such as crypto, a real Response, or a binary body, move that code to Before All or After All. See Load Test Step Limits for the complete list.