Complete the code to select the active environment in Postman.
pm.environment.set('[1]', 'production');
In Postman scripts, activeEnvironment is not a standard variable. To set an environment variable, you provide the variable name as a string. The code as given is incorrect because environmentName is not a variable you can set directly. Instead, you set environment variables by their names. This question is ambiguous because Postman does not have a built-in variable called environmentName that you can set. The correct approach is to set a variable by its name, e.g., pm.environment.set('env', 'production');
Complete the code to get the value of a variable from the current environment.
let apiUrl = pm.environment.get('[1]');
The variable apiUrl is commonly used to store the API base URL in the environment.
Fix the error in the code to switch environment variables correctly.
pm.environment.[1]('token', '12345');
get instead of set to assign values.unset or clear which remove variables.To assign a new value to an environment variable, use pm.environment.set.
Fill both blanks to correctly check if the current environment is 'staging' and set a variable.
if (pm.environment.get('[1]') === '[2]') { pm.environment.set('status', 'testing'); }
Use environmentName to get the current environment's name and compare it to 'staging'.
Fill all three blanks to create a test that verifies the environment variable 'userId' exists and is not empty.
pm.test('User ID exists', function() { let userId = pm.environment.get('[1]'); pm.expect(userId).to.[2].not.[3]; });
The test gets the userId variable, then expects it to be not null, ensuring it exists.