Notification texts go here Contact Us Buy Now!

In Postman how can I edit the request name from the "Tests" tab using javascript?

In Postman, you can dynamically edit the request name from the "Tests" tab using JavaScript. To do this, you need to set a counter in the collectionVariables with an initial value of 0. Then, in the test tab of your collection, increment the counter after each test. Finally, in the test tab of your request, use JavaScript to set the request name to "Your test name" + counter. Here's an example: ```js // in the collection tests tab let counter = pm.collectionVariables.get("counter"); counter ++; pm.collectionVariables.set('counter', counter); ``` ```js // in the request tests tab let counter = pm.collectionVariables.get('counter'); pm.test(["Your test name " + counter], function () { pm.response.to.have.status(200); }); ``` Don't forget to reset the counter in the last request of your collection. Here's an example: ```js // in the request tests tab (last request of your collection) let counter = pm.collectionVariables.get('counter'); counter = 0 pm.collectionVariables.set('counter', counter); ```

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.