If like me, you have never really coded before, but you have dabbled in this and that without any real context, then this is definitely for you. 

My task was simple, write tests that can be integrated into the pipeline so that we can test all of the endpoints for the api’s.

Simple right!

Well, it would be if you knew how to code in javascript AND you understood the postman commands! 

Fear not, for I am here to try and help you on your quest with some simple commands you will probably end up using and some examples. Hopefully this will be enough for you to try these out yourself using your own endpoints. 

What would be a great way to get your head around the syntax and how javascript works, is to head over to codeschool.com and subscribe for a month. It was £20 last time I looked, which gives you access to loads of lessons, but more importantly, they have a fantastic suite of javascript lessons which really helped me get started. 

What I am providing here aren’t lessons persey, they are more code snippet examples, so I am just going to call them “Code Snippets”. 

This is a new ongoing project, so please follow me on twitter for updates

Code Snippets #1 –  This introduces you to the simple but effective console.log() function. It is very versatile in giving feedback & great for debugging.

Code Snippets #2 – This introduces you to ‘var‘, a variable container for data. 

Code Snippets #3 – This code snippet uses an environment variable to send the request.

Code Snippets #4 – This introduces you to the if() statement.

Code Snippets #5 – This introduces you to the for() statement.

Code Snippets #6 – Automatically save the output of the response to a file. 

Code Snippets #7 – Introducing the break; function (this is covered in the for() statement).

Code Snippets #8 – Postman set Variable command

Code Snippets #9 – Generating a random value to prevent conflicts. (This is covered in the Variable Command post)

 

If you would like to see anything other than the code snippets above, please let me know and I will do my best to answer. Please remember though, I am no guru on this subject. These posts are all purely by my learning and researching with the occasional help from a friendly developer. 

 

Leave a Reply