How to write assertions in Postman (objects, arrays, nested properties)

  Рет қаралды 58,061

Valentin Despa

Valentin Despa

Күн бұрын

Пікірлер: 145
@vdespa
@vdespa 4 жыл бұрын
👉 Want to learn more about Postman? Check my complete Postman online course. vdespa.com/courses/?q=KZbin
@pumayaya
@pumayaya 3 жыл бұрын
Your postman course that I took on udemy has directly led to me receiving a pay increase simply because I became more valuable to the company through the new knowledge I acquired. Multumesc frumos Valentin!
@RonaldvanderLouw
@RonaldvanderLouw 4 жыл бұрын
Simple and clear way of explaining. Your videos make Postman even more fun and easier to use. Keep up the good work 👍
@vdespa
@vdespa 4 жыл бұрын
Thanks, will do!
@gerogoya332
@gerogoya332 Жыл бұрын
Great tutorial Valentin. I came from your Udemy course and I'm so happy with all I'm learning. Thank you
@vdespa
@vdespa Жыл бұрын
Thanks 👍
@abhishekjaiswal6024
@abhishekjaiswal6024 11 ай бұрын
Thank you Valentin, for this video. You made this look so simple and easy. Also the way you explain things is wonderful.
@vdespa
@vdespa 11 ай бұрын
You are welcome. Thank you for leaving a comment.
@hasibrahat9609
@hasibrahat9609 3 жыл бұрын
It seems easy and joyful. Thanks a lot, Valentin makes it easier.
@vdespa
@vdespa 3 жыл бұрын
You're welcome!
@denisd9575
@denisd9575 2 жыл бұрын
Thank you Valentin. Things have become clear for me !!!
@vdespa
@vdespa 2 жыл бұрын
Wonderful! Glad that it helped. You are welcome. Thank you for leaving a comment.
@willian-rattis
@willian-rattis 2 жыл бұрын
Your class it's amazing. I really liked it a lot. From 🇧🇷
@vdespa
@vdespa 2 жыл бұрын
Happy to hear that! I am glad that it was helpful.
@xyzprywatne3756
@xyzprywatne3756 4 жыл бұрын
You really explain all in videos nice, english isn't my native language and I understand all what you explain because you are talking clear, slow and with easy accent
@vdespa
@vdespa 4 жыл бұрын
Happy to hear that!
2 жыл бұрын
Thank you Valentin! This video helped me to manage challenges I was working on for a long time. So as dealing with special characters in the JSON hierarchy and finding an expected element in an array.
@vdespa
@vdespa 2 жыл бұрын
I am glad it helped. Thanks for your comment 👍
@ankitkumarsingh5910
@ankitkumarsingh5910 2 жыл бұрын
Thanku Valentin...it's getting really helpful me to understand about it. Thanks.
@vdespa
@vdespa 2 жыл бұрын
You are welcome. Thank you for leaving a comment.
@BoluwatifeDada
@BoluwatifeDada 4 жыл бұрын
Thanks for simplifying writing postman tests with JS. Looking forward to more tutorials from you
@vdespa
@vdespa 4 жыл бұрын
More to come! Thanks for your comment.
@willian-rattis
@willian-rattis 2 жыл бұрын
And I bought your course Postman: The Complete Guide - REST API Testing! Let's get started!
@vdespa
@vdespa 2 жыл бұрын
Thanks 👍 Enjoy the course.
@willian-rattis
@willian-rattis 2 жыл бұрын
@@vdespa 👍👍
@sashko-w8f
@sashko-w8f 2 жыл бұрын
Came from your Udemy course. The find method on the array is pretty handy, replaces the whole for in or forEach search for an object.
@vdespa
@vdespa 2 жыл бұрын
Yes. There are a lot of array method work exploring.
@anandpgems1141
@anandpgems1141 Жыл бұрын
thanks Valentin very helpfull your style of teaching step by step is fabulous thanks agian
@vdespa
@vdespa Жыл бұрын
Glad it was helpful! You are welcome. Thank you for leaving a comment.
@elenkailioska5752
@elenkailioska5752 Жыл бұрын
Yes Valentine, this is very useful. Pls point us more samples
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.
@aspiadas
@aspiadas Жыл бұрын
Very helpful. Thank you so much for posting this :)
@vdespa
@vdespa Жыл бұрын
Glad it was helpful! You are welcome. Thank you for leaving a comment.
@danny_dainton
@danny_dainton 4 жыл бұрын
This is awesome!! Great work again!! 🏆
@vdespa
@vdespa 4 жыл бұрын
Thank you, Danny! Cheers!
@yevhen3797
@yevhen3797 2 жыл бұрын
Thanks Valentin, this video was really helpful!
@vdespa
@vdespa 2 жыл бұрын
Glad it was helpful! You are welcome. Thank you for leaving a comment.
@mykolanesmashnyi5087
@mykolanesmashnyi5087 2 жыл бұрын
Thank you so much, sir! Extremely helpful
@vdespa
@vdespa 2 жыл бұрын
You are welcome. Thank you for leaving a comment.
@jessicasindelkova6028
@jessicasindelkova6028 2 жыл бұрын
This video was so great! Thanks a lot! Keep on going! :) Great job
@vdespa
@vdespa 2 жыл бұрын
Thank you! Will do!
@vovaka440
@vovaka440 3 жыл бұрын
Thank you for your content! I'm using your course on Udemy and I like it!
@vdespa
@vdespa 3 жыл бұрын
Thank you, Vlad!
@marlenisconcepcion4358
@marlenisconcepcion4358 Жыл бұрын
I love it, thanks Valentin😀
@vdespa
@vdespa Жыл бұрын
Glad you like it! You are welcome. Thank you for leaving a comment.
@estas9449
@estas9449 3 жыл бұрын
Thank you Valentin, you rock!
@vdespa
@vdespa 3 жыл бұрын
Thanks!
@MsMarjorine
@MsMarjorine 4 жыл бұрын
Thank you Valentin, Great video, it helped me a lot in learning Postman assertions! ❤️
@vdespa
@vdespa 4 жыл бұрын
Happy to hear that. Thanks for your comment!
@MadirajuKChaitanya
@MadirajuKChaitanya 3 жыл бұрын
Nice video tutorials, Valentin. Thank You for sharing this info. with us... :-).
@vdespa
@vdespa 3 жыл бұрын
Thank you!
@PrakashKumar-vs9xy
@PrakashKumar-vs9xy 4 жыл бұрын
Awesome....learned few new things. Thank you:)
@vdespa
@vdespa 4 жыл бұрын
Glad it was helpful!
@SvitlanaN
@SvitlanaN 2 жыл бұрын
Really helpful! Thank you)
@vdespa
@vdespa 2 жыл бұрын
Glad it was helpful! You are welcome. Thank you for leaving a comment.
@viktormelnyk6777
@viktormelnyk6777 4 жыл бұрын
Thank you Valentin! It was very useful
@vdespa
@vdespa 4 жыл бұрын
Glad it was helpful!
@Paul-w8c7h
@Paul-w8c7h 3 ай бұрын
Thank you so much! Excellent video.
@vdespa
@vdespa 3 ай бұрын
Glad you enjoyed it! You are welcome. Thank you for leaving a comment.
@qaLex455
@qaLex455 Жыл бұрын
Cool this is a great information!
@vdespa
@vdespa Жыл бұрын
Glad you think so! You are welcome. Thank you for leaving a comment.
@tholeduc5347
@tholeduc5347 2 жыл бұрын
Thanks for this tutorial
@vdespa
@vdespa 2 жыл бұрын
You are welcome. Thank you for leaving a comment.
@olenayakovlieva7926
@olenayakovlieva7926 2 жыл бұрын
Thank you! Now I know more)
@vdespa
@vdespa 2 жыл бұрын
You are welcome. Thank you for leaving a comment.
@shanikawaidyarathne2407
@shanikawaidyarathne2407 2 жыл бұрын
Thank you very much. Really helpful! Looking forward for more tutorials
@vdespa
@vdespa 2 жыл бұрын
You are welcome! I am glad that it was helpful.
@someonespecial8689
@someonespecial8689 Жыл бұрын
Another amazing lecture
@vdespa
@vdespa Жыл бұрын
Thank you! Cheers! Glad that you liked it.
@meghatiwari5225
@meghatiwari5225 4 жыл бұрын
Very good explanation, Thanks
@vdespa
@vdespa 4 жыл бұрын
You are welcome!
@bhargavidalal3915
@bhargavidalal3915 3 жыл бұрын
Very Nicely Explain
@vdespa
@vdespa 3 жыл бұрын
Thanks!
@rafaelcgol
@rafaelcgol 3 жыл бұрын
This was very helpfull, thanks!!!
@vdespa
@vdespa 3 жыл бұрын
Glad to hear. Thanks for your comment and consider subscribing.
@MrWicky77
@MrWicky77 3 жыл бұрын
Thank you, It was helpful.
@vdespa
@vdespa 3 жыл бұрын
Glad it was helpful!
@donthorpe6301
@donthorpe6301 3 жыл бұрын
thanks so much for this! saved me! lol
@vdespa
@vdespa 3 жыл бұрын
Great to hear! Thanks for the comment.
@mogliff3414
@mogliff3414 4 жыл бұрын
This is awsome 😻
@vdespa
@vdespa 4 жыл бұрын
Thank you!
@timmyocean2008
@timmyocean2008 2 жыл бұрын
great job!
@vdespa
@vdespa 2 жыл бұрын
Thanks! You are welcome. Thank you for leaving a comment.
@fridgeron1641
@fridgeron1641 Жыл бұрын
We have a json where a path leads to either a single object or an array of objects. We need to "loop" over each element and compare to another API. Is there an elegant way to do this? So far, we have code to cover both scenarios...
@vdespa
@vdespa Жыл бұрын
I would say that the API design is not great. It should be an array all the time. Probably an if-block will do it. If the API design is not elegant, the tests won't be either.
@drakezen
@drakezen 4 жыл бұрын
Great Video!
@vdespa
@vdespa 4 жыл бұрын
Glad you enjoyed it
@BrendanMetcalfe
@BrendanMetcalfe 4 жыл бұрын
Hey man I like your personal site with Gatsby. Couldn't find the source on your github/youtube. What did you need Gatsby for given its a pretty simple layout?
@vdespa
@vdespa 4 жыл бұрын
Thanks. I am using Gitlab for the code. I like experimenting with technologies and CI/CD pipelines.
@ravibabuch2750
@ravibabuch2750 2 жыл бұрын
How can we assert the value "Mailing / visiting" this special character is throwing error
@vdespa
@vdespa 2 жыл бұрын
Try something like somearray["Mailing / visiting"]
@dwarakeshthanigaivelan2199
@dwarakeshthanigaivelan2199 3 жыл бұрын
Is it possible to parameterize the expected value, for example in this case we are hardcoding "Jane", "Social-Media". Is there a way to drive it from environment variables or via a CSV file ?
@vdespa
@vdespa 3 жыл бұрын
Of course. Use a Postman variable, like pm.iterationData.get("variablename") instead of the hardcoded value.
@dwarakeshthanigaivelan2199
@dwarakeshthanigaivelan2199 3 жыл бұрын
@@vdespa I want to use the dynamic array index based on the condition. If the condition matches then I should get the respective index. How can that be done ? Can you help me on this.
@vdespa
@vdespa 3 жыл бұрын
@@dwarakeshthanigaivelan2199 It is hard to tell what you are trying to do. Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@naveensimrat6159
@naveensimrat6159 2 жыл бұрын
I am getting the error message find is not a function run running the test. any help would be appreciated..
@vdespa
@vdespa 2 жыл бұрын
It is hard to answer this with the given information. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@MotoBroom
@MotoBroom 3 жыл бұрын
Hi . This video is very useful. Can you also make a tutorial on how we can pass this object to a variable? Thanks in advance.
@gsVerka
@gsVerka 3 жыл бұрын
Hello Valentine, does find() work when we get response in xml? -----------I have seen your video on xml parsing, but sometimes find() does not work well with xml. Can you please suggest? ------------Thank you.
@vdespa
@vdespa 3 жыл бұрын
It may not work with all examples. Give it a try and see if it works for your use-case.
@danishmerchant9232
@danishmerchant9232 2 жыл бұрын
I am facing an issue while creating const person = response[1]; TypeError: Cannot read properties of undefined (reading 'name')
@vdespa
@vdespa 2 жыл бұрын
Is your response an array? Do the objects inside have a property called name?
@danishmerchant9232
@danishmerchant9232 2 жыл бұрын
@@vdespa I dont knw that
@thebaltsology246
@thebaltsology246 2 жыл бұрын
Hiw should i assert that all name is equal to jane and that it will fail. Or each name in the array is equal to jane.
@vdespa
@vdespa 2 жыл бұрын
You should iterate over each element of the array and use the assertion to.eql. However, I doubt you will ever have this use-case.
@ashutoshpratapsingh6872
@ashutoshpratapsingh6872 4 жыл бұрын
Please create some videos on Java Script basics, object and arrays
@vdespa
@vdespa 4 жыл бұрын
Thanks for the suggestion. I will do that in a next tutorial.
@ashutoshpratapsingh6872
@ashutoshpratapsingh6872 4 жыл бұрын
@@vdespa Thanks and today video last 5mint little bit confused in how to Read Array of object in Java script
@kolob204
@kolob204 2 жыл бұрын
Hi. Help me findout please, how to patch deeper field for example i need to update parent 1 or 2: { "users": [ { "id": 1, "first_name": "John", "last_name": "Smith", "parents": [ { "first_name": "Arnold", "last_name": "Terminator" }, { "first_name": "Sara", "last_name": "Conor" } ] i try do it according RFC Header: Content-Type: application/json-patch+json Body: [ {"op" : "replace", "path" : "/parents/1/first_name", "value" : "NewName"} ] But it doesnt work :-(
@vikky020
@vikky020 3 жыл бұрын
Hey, I want to extract value of item.values.name based on the value of type.id in below json snippet, Can u plz help how can i write json expression for it in postman assertions , I dont want to use array position I tried using below but failed data.item.values[?(@.type.id==25)].name data { item { Values: [ { id : 1, name: abc, type : { description: bcd, id: 25, name: ghj } }, array continues.... ]
@vdespa
@vdespa 3 жыл бұрын
It is hard to answer this with the given information. Join the Discord community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@chinmayakumarpujari2875
@chinmayakumarpujari2875 4 жыл бұрын
Hey .. I am facing a proxy issue in running postman collection through bamboo .. can you please suggest some solution
@vdespa
@vdespa 4 жыл бұрын
It is hard to know what the problem is in this case. Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@MagDag_
@MagDag_ 4 жыл бұрын
Thanks man
@vdespa
@vdespa 4 жыл бұрын
Thanks for watching!
@ashutoshpratapsingh6872
@ashutoshpratapsingh6872 4 жыл бұрын
To Good and thanks a lot
@vdespa
@vdespa 4 жыл бұрын
Most welcome
@kavithat0646
@kavithat0646 3 жыл бұрын
Hi My response body has { id: 564 firstname:apple lastname:fruit } { id:897 firstname:Tomato lastman:vegetable }etc How can I write test to get the id of Tomato vegetable from the response and set the id in the environment variable? from a GET request.Is it possible?
@vdespa
@vdespa 3 жыл бұрын
You need to learn some JavaScript. Watch this: kzbin.info/www/bejne/oKbYmZVpjJ2ripY
@kavithat0646
@kavithat0646 3 жыл бұрын
Thank you for quick response. I will go through it.
@siwabuk
@siwabuk Жыл бұрын
Thank you so much
@vdespa
@vdespa Жыл бұрын
You are welcome. Thank you for leaving a comment.
@kozakmandrivnyk2309
@kozakmandrivnyk2309 2 жыл бұрын
Why it is bringing back object in console but it is an array in fact?
@vdespa
@vdespa 2 жыл бұрын
Good question! I should have explained this better. An array is technically an object.
@kozakmandrivnyk2309
@kozakmandrivnyk2309 2 жыл бұрын
@@vdespa so it's never saying array in console?
@AhmedABED-km6fv
@AhmedABED-km6fv 3 жыл бұрын
thanks man
@vdespa
@vdespa 3 жыл бұрын
You're welcome 😁
@martinmadruga
@martinmadruga 4 жыл бұрын
Very good information! I wanted to ask you how I do an assertion when the array is like this: "social-media": [ socialm1: "Facebook" , socialm2: "Twitter" ] I would like to validate Twitter.
@vdespa
@vdespa 4 жыл бұрын
Thanks! Regarding your assertion I need more details. Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@phristo
@phristo 2 жыл бұрын
what if there are multiple emails?
@vdespa
@vdespa 2 жыл бұрын
You can use external data files to provide different sets of data.
@t0245215
@t0245215 2 жыл бұрын
how to check empty array ?
@vdespa
@vdespa 2 жыл бұрын
Check it's length.
@LuvxJacqu4li8e
@LuvxJacqu4li8e 3 жыл бұрын
Very nice
@vdespa
@vdespa 3 жыл бұрын
Thanks
@YuvanBook
@YuvanBook 3 жыл бұрын
const response = pm.response.json(); const count = response.find(item => item.total_count === 2); console.log("The applet state is :::: " + count); throws error There was an error in evaluating the test script: TypeError: response.find is not a function Postman version: Version 8.5.0 (8.5.0)
@vdespa
@vdespa 3 жыл бұрын
Find works on arrays. Most likely your response is not an array.
@immanuelsamuelgwu
@immanuelsamuelgwu 4 жыл бұрын
I have given a parameter in request(eg:date=2020-03-12) I need to verify the same date is present in response or not, by not giving the value(2020-03-12) directly in script. Because this date is dynamic and will be changed often. So I need to check the value of the date given in request is present in response using the date variable alone. I hope the question is clear
@vdespa
@vdespa 4 жыл бұрын
Have you looked into JSON schema validation? Or using a regular expression (regex)?
@soelinaung9751
@soelinaung9751 4 жыл бұрын
Thank you
@vdespa
@vdespa 4 жыл бұрын
You're welcome.
@rub3nski
@rub3nski 8 ай бұрын
this is free?? i feel like a moron
Data-driven testing using Postman
13:37
Valentin Despa
Рет қаралды 60 М.
Loop request based on data from response in Postman
13:13
Valentin Despa
Рет қаралды 62 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,3 МЛН
Learn JavaScript for Postman API testing - Full Course for Beginners
1:28:39
Consumer-driven Contract Testing using Postman
30:47
Valentin Despa
Рет қаралды 32 М.
JSON Schema validation (nested objects, arrays) in Postman  - Part II
9:11
How to write API test cases in Postman using JavaScript
15:45
Naveen AutomationLabs
Рет қаралды 89 М.
Data-driven testing with different data sets for each request
16:48
Valentin Despa
Рет қаралды 16 М.
Why Is Array/Object Destructuring So Useful And How To Use It
13:24
Web Dev Simplified
Рет қаралды 432 М.
Writing Tests in Postman - with Examples | The Exploratory
12:53
Part 9: How to put Assertions/Validations in your API tests
26:08
Automation Testing Insider
Рет қаралды 3,9 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН