# A way to create custom test snippets

**URL:** <https://community.postman.com/t/a-way-to-create-custom-test-snippets/36142>\
**Category:** Help Hub\
**Created:** [June 11, 2022, 5:33pm UTC](https://community.postman.com/t/a-way-to-create-custom-test-snippets/36142 "2022-06-11T17:33:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 11, 2022, 5:33pm UTC](https://community.postman.com/t/a-way-to-create-custom-test-snippets/36142/1 "2022-06-11T17:33:13Z")

</div>

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;

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/6/663cd9faffbcbc2eefbfa5335b4658dfc6c1dfd1.png)

You could then use eval() to run like so;

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/8/81493a1ab1f9437cb8a2f90091eb35676a1b43d3.png)

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 2:47pm UTC](https://community.postman.com/t/a-way-to-create-custom-test-snippets/36142/3 "2024-12-12T14:47:57Z")

</div>

Closed on December 12, 2024, 2:47pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
