Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Here’s an outline with best practices for making your inquiry.
My question:
I am trying to write a test to compare the response body and make decision based on it.
Details (like screenshots):
This is my script
pm.test(“Status code is 200”, function () {
pm.response.to.have.status(200);
});
var jsonData = JSON.parse(responseBody);
if(pm.response.jsonData < "0.60"){
postman.setNextRequest("water the plants");
} else {
postman.setNextRequest("null");
// Insert logic here for other tests
}
This is the error:
Tests added correctly | TypeError: Cannot read property ‘find’ of undefined
Usually, this kind of error denotes that there is an issue with the response parsing.
var jsonData = JSON.parse(responseBody);
you have already parsing the response and storing it in a variable "jsonData "
this variable will have the entire response, to reach the element inside that, you need to pick the “key”. You might have already done this before in your previous scripts. Let us know if you couldn’t still fix it
Numbers don’t need double quotes in JS. so it should be 0.60
Please check the syntax for stopping the execution
All of @bpricilla’s comments are correct (there are definitely some adjustments that you will need to make in your “should I water the plants?” script) but the error that you listed is actually coming from the Submit your solution test.
Cannot read property ‘find’ of undefined
The test is using .find in several places, in order to verify the content of your tests; so please check the following (as they would cause the above error if false):
Your first request must be named should I water the plants? (ensure the case is identical)
Your second request must be named water the plants (ensure the case is identical) (it seems this is probably correct, because you have referenced it in your test script)
I believe you have added the above script to the “Tests” section of “should I water the plants?” request. And there’s no error in the script.
Please read the documentation again and check if you have added both the request names correctly and you have added correct “Tests” for the second request “water the plants”.
After all this try submitting again and provide the screenshot which test case among the five is failing for “submit” request
For days 09 and 11, this is some of the worst (non-existent) documentation on a product ive ever seen. There is NOWHERE ANY helps of ANY KIND on how to do this branching logic in the Docs for these 30 Days collections . Just terrible.
The 30 day challenge is characterized as a challenge, so you will do some research on your own. One hint is to click through the inline links to see the documentation. The beginning of each collection also has a list of concepts covered and additional resources - those are also links that you can click on to see more docs.
Up until Day 9, the instructions to perform the operations each lesson requires were contained IN EACH Lesson, not scattered across the internet. My prior statement stands.
I think, as developers, having a little bit of Google-fu is a good thing.
Everything we need to complete these challenges are found in the Postman Learning Center and we leave all of the clues that you need in the documentation for each challenge.
Otherwise we are always open to feedback and also are happy to help out on the forums here too!
Dude , this challenge is not for you , go play soccer or relax in the park. Here you need to research and try 100 times a simple task and learn how to make it work.
Did you figure it out? I had the same issue . Make sure request names are the same and use your params in the POST request in the body (form-data). Everything is so simple but it takes some time to figure it out . Love this challenges.