HAR import & login flows
Turn browser network recordings into editable HTTP test scripts.
On this page
Choose the right working directory. Examples using
npm runshortcuts,node bin/loadstride.js, or top-levelstarter-kit/paths run from the LoadStride source checkout. Those shortcuts do not exist in your application’s package.json. Installed-package users runnpx --no-install loadstridefrom their application directory. See Getting started for both options.
Import a recorded login flow
Record a journey using the browser Network panel: enable Preserve log, clear old requests, perform the flow, and export HAR. The importer runs locally and does not visit the recorded URLs. Select one exact application host (include a nonstandard port), then generate a script:
node bin/loadstride.js import har recordings/checkout.har --host shop.example.com \
--out load-tests/checkout.js --login once-per-vu --login-steps 1
--login-steps counts the first imported requests, after filtering. Set it to
the whole login sequence (for example, a CSRF page plus the login POST). The
default --login iteration runs every request each iteration. once-per-vu skips
those initial steps after that VU’s successful login. Failed flows clear their
session; a subsequent iteration logs in again. Automatic token refresh and retries
within a failed iteration are not implemented.
Captured cookies and response bodies are excluded. Recognized sensitive header,
query, JSON, and form fields become environment placeholders such as
LOADSTRIDE_USERNAME and LOADSTRIDE_PASSWORD. Raw text bodies become LOADSTRIDE_BODY_<step>.
Authorization headers use LOADSTRIDE_AUTHORIZATION unless explicit token extraction is
configured. This is heuristic redaction: review generated scripts for application
data and unrecognized secrets before sharing them. Import prints required variable
names and skipped-request counts. It refuses to overwrite an existing script.
Cookie login works through per-VU cookie storage. For bearer-token login, add
--token-path access_token (or a dotted path like data.accessToken); the last
login step must return that JSON field. Subsequent requests use the fresh bearer
token. LoadStride does not infer SSO, MFA, CAPTCHA, CSRF, or dynamic cart/order IDs.
Edit the generated afterResponse(response, stepNumber, session) hook and request
builders for those correlations. session.state.values.LOADSTRIDE_CSRF_TOKEN, for example,
can satisfy a generated placeholder on a later request.
Iteration http now stores response cookies separately for each VU and scenario.
session.state persists between that VU’s iterations; session.reset() clears
both state and cookies. Setup/teardown HTTP contexts do not seed VU cookie sessions.
Cookies respect path, Secure, expiry, and deletion, but are restricted to the exact
response host even with a parent Domain attribute. Sibling-subdomain cookie sharing,
browser SameSite enforcement, and full browser cookie semantics are not emulated.
Each jar retains at most 300 cookies of at most 4 KiB each. Normal automatic
redirects capture cookies along the chain and strip explicit authorization/cookie
headers across origins; one helper call remains one measured request, with final
response bytes/status and full elapsed time. Imported flows instead use manual
redirects so every retained HAR step is measured separately.
Set credentials in your env file, then validate one iteration before increasing load:
node bin/loadstride.js run load-tests/checkout.js --vus 1 --iterations 1
node bin/loadstride.js run load-tests/checkout.js --rate 50 --max-vus 20 --duration 10s \
--json reports/checkout.json --html reports/checkout.html
For distinct users, set LOADSTRIDE_USERS_FILE=recordings/users.json. Each JSON row uses
the placeholder names printed at import:
[
{ "LOADSTRIDE_USERNAME": "test-user-1", "LOADSTRIDE_PASSWORD": "replace-me" },
{ "LOADSTRIDE_USERNAME": "test-user-2", "LOADSTRIDE_PASSWORD": "replace-me" }
]
VU 1 selects row 1, VU 2 row 2; supply enough rows for active VUs. Missing rows fail
rather than sharing credentials. Without this file, credentials come from env
variables and can be shared by VUs. LOADSTRIDE_BASE_URL=https://staging.example.com
replaces the original origin; it must not contain credentials, a path, or a query.
The first importer supports one host/origin per script and sequential HTTP(S) requests, JSON and URL-encoded forms. It filters known static/non-API resources, other hosts, and browser preflights; binary/multipart uploads are skipped. Redirects are imported as individual steps and replayed with automatic following disabled. Recorded timing, parallelism, browser rendering, WebSockets, and automatic dynamic value extraction are not reproduced. Files are limited to 20 MiB/10,000 entries. Review skipped requests: omitting a required step can invalidate the journey.
Try the included demo without your own recording:
npm run demo:auth-server
## In a second terminal:
node bin/loadstride.js import har starter-kit/login.har.json --host 127.0.0.1:3001 \
--out load-tests/demo-login.js --login once-per-vu --login-steps 1
LOADSTRIDE_USERNAME=demo-user LOADSTRIDE_PASSWORD=demo-password node bin/loadstride.js run \
load-tests/demo-login.js --no-env --vus 1 --iterations 2
You can also open http://127.0.0.1:3001 to record login, profile, and add-item actions
in the browser. Dummy users demo-user, demo-user-1, etc. all use demo-password.
The demo is loopback-only and is not production authentication.
Repeated logins reuse one session per username with a sliding five-minute expiry,
so repeated iterations do not fill the store. The cap is 10,000 active distinct
users; extra users receive HTTP 503. Restart the demo server after a code update.
recordings/ and *.har are ignored by Git. Keep recordings and real user data local.
Based on the released v0.2.0 guide. View source on GitHub.