1.1.1 • Published 2 years ago

newman-assert-json-template v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

newman-assert-json-template

Getting Started

This package is used to compare two jsons in postman.

How to use

Add pre-request script to your postman collection:

window = {};

pm.sendRequest(`https://unpkg.com/newman-assert-json-template@1.0.6/assertJsonTemplate.js`, (err, res) => {
    var text = res.text();
    window.assertJsonTemplate = eval(text);
});

Remember! pm.sendRequest() must contain the latest version of the image.

Positive case

For example pm.response.json():

{
    "key0": "0",
    "key1": "1",
    "key2": "2",
    "key3": "3"
}

Test case for the request to compare two jsons:

const data = {
    "key0": "0",
    "key2": "2"
}

pm.test("Example test", () => {
    window.assertJsonTemplate(pm.response.json(), data);
})

The test results will look like this:

PASS Example test

Negative case

For example pm.response.json():

{
    "key0": "0",
    "key1": "1",
    "key2": "2",
    "key3": "3"
}

Test case for the request to compare two jsons:

const data = {
    "key0": "0",
    "key2": "6"
}

pm.test("Example test", () => {
    window.assertJsonTemplate(pm.response.json(), data);
})

The test results will look like this:

FAIL Example test | AssertionError: expected '2' to deeply equal '6'
1.1.1

2 years ago

1.1.0

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago