GithubHelp home page GithubHelp logo

alexndrmac / postman_asserts Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 681 KB

Tiny scripts for Postman Auto tests (reusable Assertions for postman tests and json schema validation)

License: GNU General Public License v3.0

JavaScript 71.51% Makefile 28.49%
postman tv4 json autotesting

postman_asserts's Introduction

Postman Asserts | provide a clean way to organize tests

Build status Repository certification

If you want use Tests inside Postman, you must always write assertions like this:

pm.test('Response should have JSON Body', function () {
    pm.response.to.have.jsonBody();
});

// or
tests["Response Data is Valid"] = tv4.validate(pm.response.json(), schema);

It will be better if we can use Reusable functions inside Postman. It's more flexible...

Writing tests within Postman Reusable functions

To have Assertions inside your Collection, you need to do next steps:

  • Save content of pm_asserts.min.js script as a global variable
  • In the Postman Test scripts - eval postman_asserts global variable
  • Call Asserts functions by functions' name

Setting up Assertions Script to Postman Globals

To set up Assertions - just download Collection and make API call with it. This Request will get Script content and set up Global variable into Postman Environment.

Using Assertions inside Postman Tests

Into Tests window call Assertions after eval() Postman Globals variable, which contains Script body.

eval(globals.postman_asserts);

const schema = {
    "type": "object",
    "required": ['args', 'headers']
};

isJsonResponse();
isResponseStatus(200);
validateJsonSchema(schema);

License

This project is open source software licensed under the GNU General Public License version 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.