I am creating a new grid using a post request.
I am storing the name of the grid in the response in an env var as shown below:
const Grd = pm.response.json();
postman.setEnvironmentVariable(āgrid_nameā, Grd.name);
In my next request I am trying to create a new grid using the same name from the prev request (grid_name)
And I have to write a test to validate the following error message displayed:
āGrid with name āGrid vy56xl6xy3nā exists.ā
where āGrid vy56xl6xy3nā is the grid name from the prev request which is stored in the env var āgrid_nameā
My test looks like below where the env var doesnāt get recognized:
pm.test(āVerify error message for duplicate nameā, ()=>{
pm.expect(Grd.errors[0]).contains(āCommission grid with name {{grid_name}} exists.ā);
});
I see the following error for my test:
Verify error message for duplicate name | AssertionError: expected āGrid with name āGrid vy56xl6xy3nā exists.ā to include āGrid with name {{grid_name}} exists.ā
How should I write my test for this scenario?