Automation QA Testing Course Content

Insomnia Introduction and Installation

 

Insomnia Introduction and Installation

Let us learn what is an Insomnia and how to hit an API using the same

Kong Insomnia is a collaborative open-source API development and testing platform. Using this tool we can fully automate the API lifecycle. Build tests and linting to improve reliability with Kong Insomnia’s native CLI and CI/CD integrations. Mainly it can be used for Functional API Testing, Creating customized API test flows that provide deep validation of REST, SOAP, GraphQL, and GRPC APIs through custom Insomnia Test Suite scripts and its easy for building out CI/CD pipelines for automated API tests through platforms such as GitHub, GitLab, Jenkins, Travis CI, CircleCI is easy with Insomnia Inso, the Insomnia CLI tool.

Advantages :

1. Insomnia is lightweight and fast.
2. It has a clean and intuitive interface that is easy to navigate, even for beginners
3. Insomnia has a range of advanced features, such as environment variables, code generation, and GraphQL support.

Disadvantages :

1. Insomnia has a smaller community and less extensive documentation, making it harder to find help and resources.
2. Some users may find Insomnia’s interface too minimalistic and lacking in features.
3. Insomnia only supports REST APIs, so it may not be suitable for testing other protocols like SOAP or GraphQL.

Installation:

Visit the following website and download the desktop application suitable to the OS: https://insomnia.rest/download

Collection Creation:

  1. Launch the insomnia application.


2. Click on Create option present in the top right corner and then select Request Collection. Enter the collection name of your choice and hit enter. You will now be able to see the following screen.




3. Now create a new folder by following the below image.





4. And then add an HTTP GET request inside the same folder. Enter the URL and the other parameters that are required and then send the request.



Environment:

In Insomnia we can set common URLs & variables into one section and call them throughout the collection. Insomnia consists of 2 types of environment:
1. Base Environment
2. Sub Environment

  1. Base Environment:

This is the root environment containing data available to the current request collection, regarding what is the selected sub-environment. There is only one base environment per workspace. In the base environment, you should only keep the data that is not dependent on the execution environment (development, staging, production, etc).

2. Sub Environment:

A sub-environment behaves exactly like the base environment, except you can create many of them. However, you can have only one active at the same time. You will usually create one per execution environment: one for local development, one for staging, one for production, and so on. The base environment data will be merged with the active sub-environment data, with the priority for the latter.

Steps to set an environment URL/variable:
1. Navigate to the Environment window.
2. Select which environment you want to set.
3. And enter the data into the key-value pair in the JSON format. And close the window.








4. To use the environment URLs/variables, you must give the key inside curly brackets → {{key}}. And now you can see that the key mentioned has taken a button-like structure.




Setting environment variables — Auth Token :

Let's see how to use the response variable from one request as an input to another.

  1. Hit the Login API and get auth token from the response





2. Now for setting it as a variable, go to the environment and create another key and in its value type response and then you will able to see the auto-suggestion for the response attribute as shown below:



3. Now as we have to set the token value from the response body, we can select the body attribute.




4. Now click on the highlighted line, and you will see the pop-up window.

5. Enter the request name whose response contains the variable that you want to set as an environment variable, and also mention the JSON path of the variable whose value needs to be set. In insomnia the path starts with ‘$.’ and you can also preview the value for which the path is given.






6. Now similar to the other environment variables you can use the key of the created auth variable in the requests by mentioning the key in the braces {{key}}. Let's set it as a bearer auth token for another request.




7. And now hit the Request.

Sending Request Body:

Sending Query Parameters:

You can send the parameters in key-value pair by mentioning them under the query tab. If you want to insert the description for the query parameter then you can enable the toggle description button.



Sending Headers :

Similar to the query parameters you can send the required request headers into a key-value pair by mentioning them under the headers tab. If you want to insert the description for the query parameter then you can enable the toggle description button.



Docs Tab :

It's the section in which you can mention the detailed description of the API request. It can help the person that is new to the API collection to understand the APIs quickly. You can also edit them whenever you want.

Steps :
1. Click on the description button
2. Insert all the information and close the window.





No comments:

Post a Comment

Note: Only a member of this blog may post a comment.