I set a dynamic variable in the pre-request script using pm.environment.set(“artistName”,pm.variables.replaceIn(’{{$randomLastName}}’));
This set fine
I wanted to call it back in a test using pm.test(“Artist name is set correctly”, function(){
const jsonData = pm.response.json();
pm.expect(jsonData.contact.name).to.eql(pm.environment.get(’{{artistName}}’));
and this gave me the response: AssertionError: expected ‘Schiller’ to deeply equal undefined
hi i wanted to ask based on this, i have another place where i had a very similar scenario
i used the script you specified and its not working
i have saved an environment variable using the pre-request script: -
pm.environment.set(“minimumPayment”, pm.variables.replaceIn(’{{$randomInt}}’));
and in the body called this back using “{{minimumPayment}}” and all seems fine
However when i run a test i wrote it as follows:-
pm.test(“Minimum Payment is populated by minimumPayment”, function(){