Reputation: 74
I have been using Postman for API Testing. I am trying out bruno at the moment. (https://docs.usebruno.com/). One thing I am doing in Postman is testing if my response is valid JSON. I haven't found any information about how to do this with the bru lang.
Postman:
pm.test("Response is valid JSON", function () {
pm.response.to.be.json;
});
Bruno:
test("Response should be JSON", function() {
const data = res.getBody();
expect(res.getBody()).to. ??
});
Any help is greatly appreciated!
Upvotes: 0
Views: 1298
Reputation: 74
I did not find this in the docs but after all I could figure it out by looking at the assertions:
test("Response body should be JSON", function() {
const data = res.getBody();
expect(res.body).is.json;
});
I were also able to add a check for XML Bodys which might be insteresting for someone:
test("Response body should be XML", function() {
const data = res.getBody();
expect(res.body).startsWith("<?xml");
});
Upvotes: 0