AssertionError: expected undefined to deeply equal

Can you tell me what is wrong ?
in pre-req it is written

pm.environment.set("valueOfMsg", "Request Successfully Executed");

in post-res

pm.test("Check the value of the message parameter:" + pm.environment.get("valueOfMsg"), function () {
  var jsonData = pm.response.json();
  pm.expect(jsonData.message).to.eql(pm.environment.get("valueOfMsg"));

error Checking the value of the parameter message:Request Successfully Executed | AssertionError: expected undefined to deeply equal ‘Request Successfully Executed’

Hey @cryosat-cosmonaut-38 :wave:

Welcome to the Postman Community! :postman:

You will need to provide some contextual information here, in order for folks to know what this relates to. :pray:

snippet doesn’t work, considering it’s written correctly (

Is this for some training you’re taking? Something else? Are there links to that, that you can provide?

What are the responses of those requests that you’re testing against? Are there any snippets, codeblocks or screenshots that you can provide?

Basically, this jsonData.message is undefined so check what that value is. The Postman Console can help here.

You need to assume that no one else can see or has any knowledge of what you have in front of you - over share all the information and build a picture of the issue is so that people can help you.

This is producing the “undefined” error. Get used to console logging the elements you are trying to target. Start by console logging the whole response, and then target each element one level at a time until you get to the key/value you want to actually assert. The usual issue here is data within arrays.

Without seeing an example response. We can’t help you here.

I’m sorry, I’m still too stupid in this area)
I have screenshots from which I rewrote the code.




I rewrote everything exactly, but unfortunately the test failed.

and this

This shows that the test passed. :thinking:

Yes, but if I copy this snippet my test fails( and I can’t understand why as the code is identical

What’s returned in the the response body?

You’re asserting against that value - What value is in the response body for the message property? Is it the same for every response?

Is the structure correct? For the way you’re referencing it, it would need to be like this (Other properties might also be there):

{
    "message": "<The value you are asserting against>"
}

I can’t know this as the homework only includes screenshots and parsing of these snippets .
If you write value in the body, the test will still fail. I want to figure out why this happens, I have tried everything I can.

I think you’re better off asking who ever set that homework, for more information if you don’t understand what they want you to do.

We still haven’t see what the response body for that request looks like - the test is testing that. It’s testing whatever is returned in the message property, matches that variable value.

There is a lot of contextual information here that you’re not sharing which makes it impossible for anyone to actually provide you with a solution.

I can’t show the body because the job is an early version of postman and it has a different interface.

I can send you the json and you can have a look )

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.