Problem in the test script

Hello everyone, this is my code but I’m not sure why it is not working, I would appreciate if someone opens my eyes a little to see where my error is…

pm.test(“enviroment”, function () {

const responsejson = pm.response.json();

if(responsejson.rand) postman.setNextRequest(pm.environment.set("responseData", responsejson.rand));


Hi @agustinpulido! Welcome to the community :wave:

Trying to understand what you want to validate in this test - If you want to simply set the environmental variable, however, you do not need to place inside pm.test. Instead, just the following line of code does the job :+1:

if (responsejson.rand) pm.environment.set("responseData", responsejson.rand)

Please let me know if this is not what you want :grinning:

I could fix it, now I’m a bit lost with the next step to get the badge, y have complete all the exercises

1 Like