SoftwareTestPilot
All discussions
Sam OkaforJul 13

Postman: pre-request script vs Tests tab — what runs when?

I keep putting logic in the wrong tab and chaining requests behaves weirdly.

postmanscripting
Related learningExplore Academy skill paths

1 answer

Accepted solution

Sam OkaforJul 14

Pre-request script runs BEFORE the HTTP call — use it to set headers, mint auth tokens, generate dynamic bodies. Tests script runs AFTER the response arrives — use it for assertions and to save values (pm.collectionVariables.set) for the next request in the collection runner.