Local Variable and Environment Variable Precedence

As per variable scope “If a variable with the same name is declared in two different scopes, the value stored in the variable with narrowest scope will be used”.

So, when a local variable and environment variable is declared with same name it should store the local variable. But in the below test it is storing environment variable instead of local variable. I have declared the local variable as let Person_Name=‘LocalEnv’ in tests.

Is there anything I’m doing wrong or missing out here. Need help/explanation please.

Hey @jais21 :wave:,

Welcome to the Postman Community! :postman:

A local Postman variable would be something that using pm.variables.set() and it lives for the duration of the execution of the request/runner etc.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.