Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Here’s an outline with best practices for making your inquiry.
My question:
How in postman test use environment variable to object property name?
Details (like screenshots):
I get a response from request like this:
{
“something”: {
“81071”: “Test name 1”,
“81072”: “Test name 2”
}
How I can use environment variables to make a test of id’s i geted (81071, 81072)?
How I found the problem:
I get an object from response of my request and can’t test it with an environment variables.
I’ve already tried:
I make test like this but i have an error.
pm.test(‘Value check’, () => {
const expectedObject = {
“something”: {
“pm.environment.get(‘id1’)”: “Test name 1”,
“pm.environment.get(‘id2’)”: “Test name 2”
}
};
pm.expect(response).to.deep.include(expectedObject);
});