Postman test case insetitive

1.7k views Asked by At

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?

2

There are 2 answers

0
JackTheKnife On BEST ANSWER

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);
});
0
Patrick de Kievit On

This works for me:

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