Originally published at omerbinsaleem.com by Omer Bin Saleem (Omer Saleem).

Our test session expires about ten minutes after it is issued, and a fresh login somewhere else can end the one you are holding. Record the calls once, then replay them for every pass.

How to do it

  1. Record one pass inside a single window, with every write blocked. Attach to the page, store each xhr and fetch response with its method, url, status and body, and wait longer than feels necessary for the requests that load late.
  2. Redact while you record, not afterwards. Store no request headers, strip any JWT out of the bodies, skip the token, refresh and login URLs entirely, and chmod 600 the saved fixtures.
  3. Replay from that recording. Answer every call from the file, serve repeated calls to the same URL in recorded order because one URL can answer with different bodies, return 404 plus a misses list for anything unrecorded, and abort every write.
  4. Make the replay page look like a real desktop. The automation window can open about 800 px wide, which hid part of the page, so set a desktop viewport, and clear the autosave backup key in localStorage before each run.
  5. Accept the unsaved changes prompt instead of dismissing it. Dismissing kept the dirty page, so later runs never navigated anywhere and the pass quietly tested nothing.
  6. Keep variants as transforms over the one recording rather than new recordings: a saved record in its older shape, or a planted conflicting value that is escaped inside a serialized string in one response and plain in another. Leave the page while the mock is still routed, and read the misses list to learn what to record next.

Prompt to copy

I have a page behind a session token that expires about ten minutes after it is issued, and a walkthrough that needs more time than that. Build two small scripts for me. First, a recorder that attaches to the live page, blocks every write, and saves each xhr and fetch response with method, url, status and body, never storing request headers, stripping JWTs out of bodies, skipping auth URLs, and writing the fixtures with locked down permissions. Second, a replayer that answers each call from that recording, serves repeated calls to the same URL in recorded order, returns 404 plus a list of misses for anything unrecorded, and aborts every write. Then show me how to run one variant as a transform over the same recording instead of recording again. 

I am Omer Bin Saleem, a frontend chapter lead who builds with AI every day. One practical AI hack a day at omerbinsaleem.com. LinkedIn: omer-bin-saleem · Instagram: @iomerbinsaleem.

Written with AI assistance, from my own work notes.