Test if a variable is defined
Number of APIs: 1
We have a pm.environment.has
API to check if the environment has a particular key(variable) defined.
This would be the test you're looking for
js
pm.test('foo should exist', function () {
pm.expect(pm.environment.has('foo')).to.equal(true);
});
This is also supported as pm.globals.has
.
Here's a complete API reference of the Qodex Sandbox for reference - https://www.getQodex.com/docs/v6/Qodex/scripts/Qodex_sandbox_api_reference