Assert contains multiple strings

How to assert that variable contains multiple strings?

Something like
pm.expect(myText).to.include("text1", "text2");

Is there a ready-made solution without looping?

@e.mikhailov Since postman uses a fork of chai plugin for assertions, the library doesn’t support this feature.

Without looping over an array it won’t be possible.

Code snippet could be something like this:

let expectedStrings = ['text1', 'text2'];

expectedStrings.forEach((s) => pm.expect(responseString).to.have.string(s));
2 Likes

Thanks a lot, your solution seems compact too

1 Like