For the labels, I would define an array of my labels in the pre-script area, pass it to the post request, and then iterate over it in the test. Of course, this relies on the API itself preserving the order in which you present the labels. I imagine that you'd find out pretty quickly if that were not the case.
When testing for the labels, my tests passed without including the key for the array. I think your capital "B" in bug was actually the only thing triggering the error - in which case I'm still a little confused on when the array keys are needed. but overall this has been very helpful
Yes, you can write multiple tests, and include multiple assertions within each test. See these examples: www.postman.com/postman/workspace/test-examples-in-postman/collection/1559645-820d771d-70ab-452f-9edd-0904dbc315b8?ctx=documentation
You can put multiple assertions in a script (within the callback) as shown in the previous reply. For instance, you can put another assertion for the second label right under the first one. I tried this but I was disappointed. It seems to stop on the first failure. So if your first assertion fails, your second assertion never runs. This may be OK with you, or not. Now, that said, if you want to test 200 and 404 (or other failures) you probably need to change the URL or the post data in order to force the various responses. Supposing you want to ask for a primary key that doesn't exist, to determine 404. I suspect you'd need to set up a separate call within the collection. I haven't seen this discussed yet in this series of videos. Isn't this fun? Srsly, I'm having a blast.
For the labels, I would define an array of my labels in the pre-script area, pass it to the post request, and then iterate over it in the test. Of course, this relies on the API itself preserving the order in which you present the labels. I imagine that you'd find out pretty quickly if that were not the case.
When testing for the labels, my tests passed without including the key for the array. I think your capital "B" in bug was actually the only thing triggering the error - in which case I'm still a little confused on when the array keys are needed. but overall this has been very helpful
Great video thanks
Thanks for watching!
can I test more than 2 kinds of responses per script??, lets say I want to test 200 and 404 responses to work propertly in the same endpoint
Yes, you can write multiple tests, and include multiple assertions within each test. See these examples: www.postman.com/postman/workspace/test-examples-in-postman/collection/1559645-820d771d-70ab-452f-9edd-0904dbc315b8?ctx=documentation
You can put multiple assertions in a script (within the callback) as shown in the previous reply. For instance, you can put another assertion for the second label right under the first one. I tried this but I was disappointed. It seems to stop on the first failure. So if your first assertion fails, your second assertion never runs. This may be OK with you, or not. Now, that said, if you want to test 200 and 404 (or other failures) you probably need to change the URL or the post data in order to force the various responses. Supposing you want to ask for a primary key that doesn't exist, to determine 404. I suspect you'd need to set up a separate call within the collection. I haven't seen this discussed yet in this series of videos. Isn't this fun? Srsly, I'm having a blast.
I tried following the exact lesson but my labels got dropped. Probably I need to regenerate my bearer token.
And... the description of the bug when I did the variables part showed {{randomBs}} in my repository
Totally user error, missed a $ and used label instead of labels.