Reusability / POM / DRY?

Hello,

The ability of working with variables, tests, collections, pre-scripts is great and has been definitely made our life easier, but things need to be reproached when dealing with big test suites of >200 requests with >800 assertions.

Iā€™m curious to know if somebody has a more elegant solution of maintaining a collection of this size, using some reusability concepts while using the best we can from what postman has to offer.

  1. In collection/Pre-Request Scrips tab I have all my functions stored. It is more of a general/fast place to store data, search and update globally.

Ex:

postman.setGlobalVariable(ā€œcommonTestsā€, () => {
var jsonData = pm.response.json();

function checkjSonBodyValidateOthersShort(jsonData, address, status, sub_status, data, did_you_mean) {
pm.test(ā€œResponse body is correctā€, function (){

pm.expect(jsonData.address).to.eql(address);
pm.expect(jsonData.status).to.eql(status);
pm.expect(jsonData.sub_status).to.eql(sub_status);
pm.expect(jsonData.data).to.eql(data);
pm.expect(jsonData.did_you_mean).to.eql(did_you_mean);

});
}

switch(jsonData.address)
{

    //Valid andrei
case ā€˜andreiā€™:
    eval(checkjSonBodyValidateOthersShort)(jsonData,ā€™andrei,ā€™valid',"", false, null,);    
    break;

//Invalid andrei
case ā€˜andrei2ā€™:
eval(checkjSonBodyValidateOthersShort)(jsonData,ā€™andrei2,ā€™invalidā€™,ā€ā€, true, null,);
break;
ā€¦ā€¦ā€¦ā€¦ā€¦
default:
pm.test(Address not found in case statements, function () {
pm.expect(jsonData.address).to.eql(ā€˜undefinedā€™);
});

function checkResponseTime(value) {
pm.test(Response time is less than ${value}ms, function () {
pm.expect(pm.response.responseTime).to.be.below(value);
});
}

  1. I have structured most of my requests in folders with the same purpose. Ex: type of requests, methods, headers or other criteria that will allow tests to be executed and calling into collection or folder/Test tab all my tests
    Ex:
    commonTests.checkjSonBodyValidateOthersShort();
    commonTests.checkResponseTime(2500);

Same approach for asserting header, response code, specific body, etc.

Does someone use a different strategy that could allow scaling with Postman more efficient, using reusability, POM or DRY principles?