The script fails at init with `ReferenceError: BASE_URL is not defined`.

BeginnerTroubleshootingk6 Load Testing
Answer

Likely causes → Environment variables are not globals in k6; they are read from __ENV.

Diagnose → Search the script for bare BASE_URL.

Fix →

const BASE_URL = __ENV.BASE_URL || 'http://localhost:8080';

and run with k6 run -e BASE_URL=http://checkout.shop:8080 test.js.

Prevent → Validate required env vars at the start of setup() and fail fast with a clear message.

All SRE & Reliability questions Roadmap: SRE & incident response

More on k6 Load Testing