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

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 145

  • @vdespa
    @vdespa  4 ปีที่แล้ว +6

    👉 Want to learn more about Postman? Check my complete Postman online course.
    vdespa.com/courses/?q=TH-cam

  • @pumayaya
    @pumayaya 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +10

    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 ปีที่แล้ว +1

      Thanks, will do!

  • @gerogoya332
    @gerogoya332 ปีที่แล้ว +2

    Great tutorial Valentin. I came from your Udemy course and I'm so happy with all I'm learning. Thank you

    • @vdespa
      @vdespa  ปีที่แล้ว

      Thanks 👍

  • @willian-rattis
    @willian-rattis 2 ปีที่แล้ว +1

    And I bought your course Postman: The Complete Guide - REST API Testing! Let's get started!

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      Thanks 👍 Enjoy the course.

    • @willian-rattis
      @willian-rattis 2 ปีที่แล้ว

      @@vdespa 👍👍

  • @abhishekjaiswal6024
    @abhishekjaiswal6024 9 หลายเดือนก่อน

    Thank you Valentin, for this video. You made this look so simple and easy. Also the way you explain things is wonderful.

    • @vdespa
      @vdespa  9 หลายเดือนก่อน

      You are welcome. Thank you for leaving a comment.

  • @hasibrahat9609
    @hasibrahat9609 3 ปีที่แล้ว +1

    It seems easy and joyful. Thanks a lot, Valentin makes it easier.

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      You're welcome!

  • @denisd9575
    @denisd9575 ปีที่แล้ว +1

    Thank you Valentin. Things have become clear for me !!!

    • @vdespa
      @vdespa  ปีที่แล้ว +1

      Wonderful! Glad that it helped. You are welcome. Thank you for leaving a comment.

  •  2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

    Thanku Valentin...it's getting really helpful me to understand about it. Thanks.

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      You are welcome. Thank you for leaving a comment.

  • @willian-rattis
    @willian-rattis 2 ปีที่แล้ว +1

    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.

  • @sashko-w8f
    @sashko-w8f 2 ปีที่แล้ว +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 ปีที่แล้ว +1

      Yes. There are a lot of array method work exploring.

  • @BoluwatifeDada
    @BoluwatifeDada 4 ปีที่แล้ว +2

    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.

  • @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!

  • @vovaka440
    @vovaka440 3 ปีที่แล้ว +2

    Thank you for your content! I'm using your course on Udemy and I like it!

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      Thank you, Vlad!

  • @anandpgems1141
    @anandpgems1141 ปีที่แล้ว

    thanks Valentin very helpfull your style of teaching step by step is fabulous thanks agian

    • @vdespa
      @vdespa  ปีที่แล้ว +1

      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.

  • @danny_dainton
    @danny_dainton 4 ปีที่แล้ว +2

    This is awesome!! Great work again!! 🏆

    • @vdespa
      @vdespa  4 ปีที่แล้ว +1

      Thank you, Danny! Cheers!

  • @jessicasindelkova6028
    @jessicasindelkova6028 2 ปีที่แล้ว +1

    This video was so great! Thanks a lot! Keep on going! :) Great job

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      Thank you! Will do!

  • @aspiadas
    @aspiadas ปีที่แล้ว +1

    Very helpful. Thank you so much for posting this :)

    • @vdespa
      @vdespa  ปีที่แล้ว

      Glad it was helpful! You are welcome. Thank you for leaving a comment.

  • @MsMarjorine
    @MsMarjorine 4 ปีที่แล้ว +1

    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!

  • @yevhen3797
    @yevhen3797 2 ปีที่แล้ว

    Thanks Valentin, this video was really helpful!

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      Glad it was helpful! You are welcome. Thank you for leaving a comment.

  • @mykolanesmashnyi5087
    @mykolanesmashnyi5087 2 ปีที่แล้ว +1

    Thank you so much, sir! Extremely helpful

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      You are welcome. Thank you for leaving a comment.

  • @MadirajuKChaitanya
    @MadirajuKChaitanya 3 ปีที่แล้ว +1

    Nice video tutorials, Valentin. Thank You for sharing this info. with us... :-).

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      Thank you!

  • @marlenisconcepcion4358
    @marlenisconcepcion4358 ปีที่แล้ว +1

    I love it, thanks Valentin😀

    • @vdespa
      @vdespa  ปีที่แล้ว

      Glad you like it! You are welcome. Thank you for leaving a comment.

  • @estas9449
    @estas9449 3 ปีที่แล้ว +1

    Thank you Valentin, you rock!

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      Thanks!

  • @PrakashKumar-vs9xy
    @PrakashKumar-vs9xy 4 ปีที่แล้ว +2

    Awesome....learned few new things. Thank you:)

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      Glad it was helpful!

  • @Paul-w8c7h
    @Paul-w8c7h หลายเดือนก่อน

    Thank you so much! Excellent video.

    • @vdespa
      @vdespa  หลายเดือนก่อน

      Glad you enjoyed it! You are welcome. Thank you for leaving a comment.

  • @SvitlanaN
    @SvitlanaN ปีที่แล้ว +1

    Really helpful! Thank you)

    • @vdespa
      @vdespa  ปีที่แล้ว +1

      Glad it was helpful! You are welcome. Thank you for leaving a comment.

  • @viktormelnyk6777
    @viktormelnyk6777 4 ปีที่แล้ว +1

    Thank you Valentin! It was very useful

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      Glad it was helpful!

  • @qaLex455
    @qaLex455 ปีที่แล้ว +1

    Cool this is a great information!

    • @vdespa
      @vdespa  ปีที่แล้ว +1

      Glad you think so! You are welcome. Thank you for leaving a comment.

  • @tholeduc5347
    @tholeduc5347 2 ปีที่แล้ว +1

    Thanks for this tutorial

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      You are welcome. Thank you for leaving a comment.

  • @olenayakovlieva7926
    @olenayakovlieva7926 2 ปีที่แล้ว +1

    Thank you! Now I know more)

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      You are welcome. Thank you for leaving a comment.

  • @someonespecial8689
    @someonespecial8689 ปีที่แล้ว

    Another amazing lecture

    • @vdespa
      @vdespa  ปีที่แล้ว

      Thank you! Cheers! Glad that you liked it.

  • @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.

  • @bhargavidalal3915
    @bhargavidalal3915 3 ปีที่แล้ว

    Very Nicely Explain

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      Thanks!

  • @meghatiwari5225
    @meghatiwari5225 4 ปีที่แล้ว

    Very good explanation, Thanks

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      You are welcome!

  • @rafaelcgol
    @rafaelcgol 2 ปีที่แล้ว

    This was very helpfull, thanks!!!

    • @vdespa
      @vdespa  2 ปีที่แล้ว +1

      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!

  • @timmyocean2008
    @timmyocean2008 2 ปีที่แล้ว +1

    great job!

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      Thanks! You are welcome. Thank you for leaving a comment.

  • @donthorpe6301
    @donthorpe6301 3 ปีที่แล้ว +1

    thanks so much for this! saved me! lol

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      Great to hear! Thanks for the comment.

  • @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 ปีที่แล้ว +1

      Thanks. I am using Gitlab for the code. I like experimenting with technologies and CI/CD pipelines.

  • @mogliff3414
    @mogliff3414 4 ปีที่แล้ว +2

    This is awsome 😻

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      Thank you!

  • @drakezen
    @drakezen 4 ปีที่แล้ว +1

    Great Video!

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      Glad you enjoyed it

  • @siwabuk
    @siwabuk ปีที่แล้ว

    Thank you so much

    • @vdespa
      @vdespa  ปีที่แล้ว

      You are welcome. Thank you for leaving a comment.

  • @AhmedABED-km6fv
    @AhmedABED-km6fv 3 ปีที่แล้ว +1

    thanks man

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      You're welcome 😁

  • @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.

  • @MagDag_
    @MagDag_ 4 ปีที่แล้ว +1

    Thanks man

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      Thanks for watching!

  • @ashutoshpratapsingh6872
    @ashutoshpratapsingh6872 4 ปีที่แล้ว +1

    To Good and thanks a lot

    • @vdespa
      @vdespa  4 ปีที่แล้ว

      Most welcome

  • @LuvxJacqu4li8e
    @LuvxJacqu4li8e 3 ปีที่แล้ว

    Very nice

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      Thanks

  • @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.

  • @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.

  • @ashutoshpratapsingh6872
    @ashutoshpratapsingh6872 4 ปีที่แล้ว +1

    Please create some videos on Java Script basics, object and arrays

    • @vdespa
      @vdespa  4 ปีที่แล้ว +2

      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

  • @soelinaung9751
    @soelinaung9751 3 ปีที่แล้ว

    Thank you

    • @vdespa
      @vdespa  3 ปีที่แล้ว

      You're welcome.

  • @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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      @@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.

  • @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"]

  • @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.

  • @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.

  • @martinmadruga
    @martinmadruga 3 ปีที่แล้ว

    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  3 ปีที่แล้ว

      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.

  • @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.

  • @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

  • @kozakmandrivnyk2309
    @kozakmandrivnyk2309 2 ปีที่แล้ว +1

    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?

  • @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: th-cam.com/video/juuhb3W8xT4/w-d-xo.html

    • @kavithat0646
      @kavithat0646 3 ปีที่แล้ว

      Thank you for quick response. I will go through it.

  • @t0245215
    @t0245215 2 ปีที่แล้ว

    how to check empty array ?

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      Check it's length.

  • @vikky020
    @vikky020 2 ปีที่แล้ว

    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  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.

  • @phristo
    @phristo 2 ปีที่แล้ว

    what if there are multiple emails?

    • @vdespa
      @vdespa  2 ปีที่แล้ว

      You can use external data files to provide different sets of data.

  • @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 :-(

  • @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)?

  • @rub3nski
    @rub3nski 7 หลายเดือนก่อน

    this is free?? i feel like a moron