- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set a Test in Postman with JavaScript Method?
We can set a Test in Postman with JavaScript method. In Postman, a test executes provided a Request is successful. This is because a test is created to include checkpoint and validate various parameters of the Response.
Tests implemented in the JavaScript method are written within the Tests tab.
Add the below JavaScript test −
tests["Verify Response Time"] = responseTime > 600
The tests is a variable of type array which can store data types- integer, string, Boolean and so on. Verify Response Time is the test name. The responseTime captures the time taken to obtain the Response.
Select a GET request and enter an endpoint then click on Send.
Click on the Test Results tab in Response.
The Test Results tab shows the test passed in green color. Response shows the code as 200 OK and time as 56ms (test checks if the Response time is greater than 30ms).
- Related Articles
- How to set Multiple Tests for a Request in Postman with JavaScript Method?
- How to set Test and Collection Runner in Postman?
- How to set Tests using Functional Method in Postman?
- How to set a global variable in Postman?
- Test and Collection Runner in Postman
- JavaScript RegExp test() Method
- Setting test iterations using Newman (Postman)
- How to skip a particular test method in TestNG?
- How does running a specific test method depend on another test method in TestNG?
- How to include and exclude test methods from a set of test cases in Cucumber?
- How to set text in tag with JavaScript?
- How to set the type of positioning method used for an element with JavaScript?
- How to set outline color with JavaScript?
- How to Use WebDriver Javascript Executor to Navigate to a URL using Postman?
- How to set priority to the test cases in TestNG?
