hello
I’m using the eval function to set the functions I’ve created at the folder level in both the prerequest script and test script, and am reusing those functions in the individual requests for the collection runs, like this:
if(postman.__execution.cursor.position !== 0) {
eval(pm.collectionVariables.get(“folderLevelTests”))();
}
the folderLevelTests are running setNextRequest for different conditions using different data for requests in the folder.
My goal, if it’s possible, is to get the name or ID of the first and last requests in the folder from the test script…or to get the requests that were selected from the collection runner (or in some other way that you’d recommend that makes more sense than my logic), so that I can add conditional logic for defining set-up data in Request 1’s pre-request script; and if it’s Request 3 setNextRequest to the first request in the next folder.
I’d like to be able to add requests between Request 1 and Request 3 and have the tests run to completion with the predefined datasets while setting the next request to the first request in the next folder.
Folder A → pre-request and test script defined and set as functions
Request 1 → call folderLevelTests
Request 2 → call folderLevelTests
Request 3 → call folderLevelTests
Folder B → same pattern as above for folder and requests
Request 4
Request 5
Thanks for reading all of this!