As from the documentation, both pre-request scripts and test are run in the order:
- Collection
- Folder
- Request
This way I’m trying to define a function at the Collection level and call it at Folder and Request level.
Is it possible?
Example:
// Collection pre-request script
function foo(){
console.log('bar')
}
// Request pre-request script
foo()
By now it interupt the resquest to be sent with the error message:
There was an error in evaluating the Pre-request Script:
ReferenceError: foo is not defined
There’s any other way to achieve that: Be able to define a function in collection level and access it at the sub-levels?
Thanks!!