chokachi
chokachi

Reputation: 7

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?

Upvotes: 0

Views: 835

Answers (1)

eerriicc
eerriicc

Reputation: 1240

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);

Upvotes: 0

Related Questions