How to test if property at least has something?

Im writing tests and have to check that a property at least has some text. I dont care what the text is but that it at least has something in it. It cannot be empty. My json is converted from xml with xml2json component.

pm.expect(responseJson.commentlines.commentline).to.have.property('comment');
pm.expect(responseJson.commentlines.commentline.comment).to.eql('There is at least something here');

Hey @hfhInventio :wave:

For something basic, you could use:

pm.test('Value is a string and not empty', () => {
    pm.expect(responseJson.commentlines.commentline.comment).to.be.a('string').and.not.be.empty
})

https://www.chaijs.com/api/bdd/#method_empty

1 Like

Works. This is exactly how I would like it to be.

Thank you very much

1 Like