at.export
The at.export namespace lets an After All script build a ready-to-send report of whatever just finished running — either a flow or a load test. With three simple calls you can hand back a JSON summary, a fully-rendered HTML report, or a PDF file. This is the namespace that makes Atrahasis useful inside a CI/CD pipeline without any extra plumbing.
Three Methods
- •at.export.json() — returns the run results as a JSON string in OpenTelemetry format. Synchronous; call it directly without await.
- •at.export.html() — returns the run results as a rendered HTML report string — the same layout you would see in the app, embeddable in an email or a webhook payload. Synchronous.
- •at.export.pdf() — returns a PDF file as a Promise<Uint8Array>. You must await it. The bytes can be posted straight to any endpoint that accepts application/pdf.
When at.export Works
at.export only makes sense after a run has produced results, so it is tightly scoped:
- •After All of a flow or After All of a load test, during a real run: all three methods are available and return the current run's results.
- •Anywhere else — pre-script, post-script, Before All, standalone request scripts — calling any of the three throws Error: at.export is only available in AfterAll scripts.
Flow and Load Test — Same API, Different Content
The three methods have the same name and the same return types whether you are in a flow After All or a load test After All. Under the hood they assemble different reports:
- •In a flow After All, the reports describe the flow run — every step's request, response, assertions, extracted variables, and timings.
- •In a load test After All, the reports describe the load test run — spec name, test type, aggregated metrics, thresholds, and per-step breakdowns.
Try Button and at.export
The Try button on an After All editor runs the script without running the flow or load test first — so no results exist yet. In load test After All, Atrahasis remembers the most recent run and feeds it to at.export, so Try can preview the report. In flow After All, at.exportis not wired up for Try — to preview the output, run the flow once with a stub After All (no at.exportcalls) and then add the export code.
Example — Post Reports to a Results Endpoint
After All script of a flow or load test:
// JSON (OpenTelemetry format) — great for machine processing.
const json = at.export.json();
await fetch("https://your-endpoint/results", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: json,
});
console.log("JSON report sent:", json.length, "bytes");
// HTML — readable in a browser or an email client.
const html = at.export.html();
await fetch("https://your-endpoint/report", {
method: "POST",
headers: { "Content-Type": "text/html" },
body: html,
});
console.log("HTML report sent:", html.length, "bytes");
// PDF — archivable, attachable. Note the await: pdf() is async.
const pdf = await at.export.pdf();
await fetch("https://your-endpoint/report", {
method: "POST",
headers: { "Content-Type": "application/pdf" },
body: pdf,
});
console.log("PDF report sent:", pdf.length, "bytes");