Hello! I need help. I have an API request and I have 2 positive responses with different texts inside. I want to make 1 test for both variants. for example:
pm.test(“Body matches text1 or text2”, function () {
pm.expect(pm.response.text()).to.include(“text1” | “text2”);
});
Unfortunatly, it doesn’t work for both variants. Can you suggest a decision?
@Viktor.Sergienko Instead of comparing them like that, you can use lodash
Put the following in your test script:
var _ = require('lodash');
pm.test("Body matches text1 or text2", function() {
let body = pm.response.text(),
includesText = _.includes(body, "text1") || _.includes(body, "text2");
pm.expect(includesText).to.be.true;
});