pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("健康");
});
When I use the code above to test weather the response contains the chinese word “健康”,the test fails(The response actually contains the word). I have tried to google for the solutions, but can’t work it out. Hope someone can help.
Your response is returning JSON, is there a reason you’re trying to assert against the whole response as a string and not target the specific property?
Something like this:
pm.test("Body matches string", function () {
pm.expect(pm.response.json()[0].node.title).to.equal("健康");
});
The question is that I want to use pm.expect(pm.response.text()).to.include(“健康”) because of its convenience(While using pm.response.json(), I have to designate the exact node by using dot (.) notation).
Is there a solution pm.response.text() can work with Chinese?