How to create new test snippets

Is there a way to create your own test snippets, so that common tests for requests can be easily added to multiple?

3 Likes

Really nice feature it would be nice to have

This really should be a feature. This way testing is consistent and even more importantly the test names are consistent.

Hi @DLazaridis4HEM, @praveendvd, @archerZ

Just spotted this and found it a really interesting question… I had an idea for how this could be done…

So if you create a global variable and set the value to be your pm.test snippet like this;

You could then build a little function that grabs the global variables… which in turn appears to trigger the test runs and output the pass/fail results like so;

(I’m new to JS so there may be a better way to do this… but it seems to work).

you can do the second part even simpler like this;

image

1 Like

Yes we could do the second one , but first one is just replacing the test name with the variable value , it’s not actually executing anything .:heavy_heart_exclamation::tada::tada:

But having test snippet or any custom snippet would be a really nice

first one is just replacing the test name with the variable value

:rofl: yes, now you’ve said it, I can see it! … oops
(Note to self, don’t try to write code when tired!)

1 Like