Files
bruno/packages/bruno-tests/collection/scripting/api/res/getSize.bru
2025-09-07 21:49:11 +05:30

38 lines
675 B
Plaintext

meta {
name: getSize
type: http
seq: 8
}
get {
url: https://www.httpfaker.org/api/random/json?size=1mb
body: none
auth: inherit
}
params:query {
size: 1mb
}
script:post-response {
console.log(res.getSize())
}
tests {
test("test body size", function() {
const bodySize = res.getSize().body;
// 1MB = 1024*1024 = 1048576
expect(bodySize > 1048576).to.be.true;
});
test("test header size", function() {
const bodySize = res.getSize().header;
expect(bodySize === 305).to.be.true;
});
test("test total size", function() {
const sizes = res.getSize();
expect(sizes.total).to.equal(sizes.header + sizes.body);
});
}