npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

insomnia-plugin-response-validator

v3.0.0

Published

A plugin to perform validation on the response & run all requests of folder

Downloads

970

Readme

insomnia-plugin-response-validator

This is a plugin for Insomnia API client that can validate the response based upon expected result for collection requests. We can also run all requests in a given folder in parallel using this and share with you execution results.

Installation

Install insomnia-plugin-response-validator plugin from Preferences > Plugins.

Usage

Add a header INSOMNIA-RESPONSE-VALIDATOR with a json comparising of jsonpath and expected values to assert individual response

Setup the Header

Validator

Key: JSONPATH Value: Expected Value

Note: To validate the response code of the request add "INSA-ResponseCode":"200".

The plugin is integrated with Hamjest, provides significant matcher functionality. Since JSONPATH outputs arrays, we must use array-related matchers. Some of the examples are as follows.

All hamjest to be available as __.

hasItems

"$.data[*].id" : "__.hasItem(7)"
"$.data[*].id" : "__.hasItem(__.greaterThan(8))"
"$.data[*].id" : "__.hasItem(__.lessThan(3))"

hasSize()

"$.data[*].employee_name" : "__.hasSize(5)"
"$.data[*].employee_name" : "__.hasSize(__.lessThan(3))"
"$.data[*].employee_name" : "__.hasSize(__.greaterThan(8))"

isEmpty()

"$.data[*].employee_name" : "__.isEmpty()"

contains

"$.data[*].id" : "__.contains(5, 7, 10)"

hasProperty

"$.data[0]":"__.hasItems(__.hasProperties({'id': 7,'email': '[email protected]','first_name': 'Michael','last_name': 'Lawson','avatar':'https://reqres.in/img/faces/7-image.jpg'}))"

Refer https://github.com/rluba/hamjest/wiki/Matcher-documentation for more details on matchers

INSOMNIA-RESPONSE-VALIDATOR: { "INSA-ResponseCode":"200", "$.page":"__.hasItem(2)", "$.total_pages":"__.hasItems(__.lessThan(4))" "$.status" :"__.hasItem('success')", "$.data[0].first_name":"__.hasItems('Michael')", "$.data[10].avatar" :"__.hasItems('https://reqres.in/img/faces/9-image.jpg')" }

Note: use single quote as shown above for string

Old Header Format (No longer supported)

INSOMNIA-RESPONSE-VALIDATOR:{"INSA-ResponseCode":"200", "$.status" : "success", "$.data[10].employee_name" : "Jena Gaines"}

New Header

INSOMNIA-RESPONSE-VALIDATOR: {"INSA-ResponseCode":"200", "$.status" : "__.hasItem('success')", "$.data[10].employee_name" : "__.hasItem('Jena Gaines')"}

Test Execution Result

Test Execution result will be appended at the top of the response as follows

More info for Debug

View-->Toggle DevTools-->Console

Run All Requests: Parallel or Sequential

Right click on the target folder on the context menu --> click Run All Requests-Parallel, it will trigger all requests in parallel.

Right click on the target folder on the context menu --> click Run All Requests-Sequential, it will trigger requests present in the folder sequentially. It's beneficial when requests have interconnected dependencies.

Once all the requests processed, it will open up the execution dialog window which will give the execution result.

During execution, it will evalutes the assert that setup as header against the response, based upon the assert, it will pass or fail the result. In the absence of an assert setup, a status code will be returned.

Before running all request, setup the Request timeout to desired value otherwise requets will continue run, till timeout.

Insomania-->Settings...-->Insomania Preferences

You need to have NodeJS installed in your system to use this plugin