In the version 7.6.0
, which is currently on the Canary Channel but soon to be released, you can achieve this by using the new replaceIn()
function.
I modified your code slightly to add this new feature in there:
pm.environment.set("employeeName", getRandomName());
function getRandomName() {
const employeeName = pm.variables.replaceIn("{{$randomFirstName}}");
return employeeName;
}
Or you could just get rid of that function and do it in one line
pm.environment.set("employeeName", pm.variables.replaceIn("{{$randomFirstName}}"));