@tester20183450 You can read this SO thread to understand it better
Using the recommended format of writing tests using pm.test
, you can check if the object is empty.
pm.test('The args should be empty', function () {
pm.expect(jsonData.args).to.eql({});
});
In addition to what @singhsivcan mentioned, you should also look into using the new Postman testing format (see the Snippets for a quick start).
The following assertion will work using eql :
pm.expect({a: 1}).to.eql({a: 1})
@tester20183450
If you want to confirm an object was returned, you could do this with the following:
pm.test("Expect 'args' to be an object", function() {
pm.expect(jsonData.args).to.be.an("object");
});
I can see you’re using the “old” syntax to write tests, so I’m guessing this could be done with the following - I haven’t used this syntax in over a year so it could be wrong:
tests["Expect 'args' to be an object"] = typeof jsonData.args === "object";