postman-app-support
postman-app-support copied to clipboard
V10 supported pm.environment.name in test scripts, but V11 this variable comes back as undefined.
Is there an existing issue for this?
- [X] I have searched the tracker for existing similar issues and I know that duplicates will be closed
Describe the Issue
V10 supported pm.environment.name in test scripts, but V11 this variable comes back as undefined.
Tests that used the environment.name worked in V10, but after upgrading to V11, that variable no longer works.
Steps To Reproduce
Test Script as an example:
if (pm.environment.name.indexOf("SomeExpectEnvironment") < 0) {
throw new Error("Incorrect Environment selected(SomeExpectEnvironment one should be selected): " + pm.environment.name);
}
In V10, the above works as a before invoke script, but after upgrading to V11, it throws:
Cannot read properties of undefined (reading 'indexOf')
Screenshots or Videos
No response
Operating System
macOS
Postman Version
11.0.5
Postman Platform
Postman App
User Account Type
Signed In User
Additional Context?
No response
@mwaarna-tgm Thank you for reaching out to us. Can you confirm whether you are selecting the environment in the v11 app before sending the request? I am trying to replicate the issue you mentioned, but I am unable to do so. For your reference, I have attached a video as well.
When pm.environment.name is accessed without selecting an environment, it returns 'undefined' [similar behaviour in V10].
https://github.com/postmanlabs/postman-app-support/assets/85243040/653ba6ed-156b-4cf3-9d70-f0dc8acde780
@sandeep-singh-pstmn I am experiencing the issue in postman 11.0.6, and yes I have a environment selected.
I am doing the check in Before Invoke and On a GRPC collection.
So just tried it, and it looks to affect only GRPC collections not regular json end points.
@mwaarna-tgm Thank you for the details, I was able to recreate the issue.
We had made some upgrades to our systems, and this seems to be rooting from there. Re-opening the gRPC request tab should fix this for you.
@mwaarna-tgm This has been fixed in the latest version of Postman (v11.8.0).