There was a post about creating custom test snippets and I thought it would be worth sharing my idea here too…
So Postman has a list of snippets for common tests that can be added with a simple ‘click of a button’.
But the ability to make your own snippets means that you could ensure naming conventions remain the same throughout scripting and also potentially provides a reduction in the amount of time spent creating tests (amongst other benefits).
My idea:
(Note - I have used the 200 and response time snippets as examples but this should also work for customised tests in the same format etc).
So if you create a global variable and set the value to be your pm.test snippet like this;
You could then use eval() to run like so;
(I’m new to JS so there may be a better way to do this… but it seems to work).