'Postman test case insetitive

I have a test case in the Postman which looks like:

pm.test("Last Name contains Bob", () => {
    const responseJson = pm.response.json();
    pm.response.to.have.status(200);
    pm.response.json().result.length >= 1;
    pm.expect(responseJson.result[0].last_name).to.include.a("Bob");
});

but that fail for a result which has BOBBY as last_name

I thought that by adding a to the assertion it will became case insensitive.

So what I'm doing wrong?



Solution 1:[1]

Solution for my case wast to use match with Regex

pm.test("Last Name contains Bob", () => {
    const responseJson = pm.response.json();
    pm.response.to.have.status(200);
    pm.response.json().result.length >= 1;
    pm.expect(responseJson.result[0].last_name).to.match(\Bob\gmi);
});

Solution 2:[2]

This works for me:

        pm.expect(someprop.toLowerCase()).to.include("<some_lower_case_string>");

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JackTheKnife
Solution 2 Patrick de Kievit