Search code examples
apitestingpostmanweb-api-testingpostman-testcase

Postman: Test to check the number of response body lines


looking at the provided screenshot enter image description here

In the response at Pretty section, I have 36 lines of data. I would like to write a test for this request, which would check if the response body lines were 36 each time the request is run. What would be your suggested test code for this test?


Solution

  • I had the same problem. Here's my solution:

    let text = pm.response.text();
    let lines = text.split("\n");
    let length = lines.length;
    pm.expect(length).to.eql(36);