-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Collection-Level Pre/Post Request Scripts #334
Comments
Yes, we will implement this. The plan is to have In the meanwhile, I also want to propose a concept called Hooks DesignA property called "hooks" can be added to the {
"version": "1",
"name": "bruno-testbench",
"type": "collection",
"hooks": "./hooks.js"
} The const preRequest = ({
request,
envVars,
collectionVariables,
collectionPath,
processEnvVars
}) => {
// do something with the request
return request;
};
const postRequest = ({
response,
envVars,
collectionVariables,
collectionPath,
processEnvVars
}) => {
// do something with the response
return response;
};
module.exports = {
preRequest,
postRequest
} Hooks is medium level feature that can be implemented by our community. I am hoping we should be able to enhance our existing script scripting run time make hooks work. @DivyMohan14 You have experience with our script runtime, Let me know what you think of this approach and if you have some bandwidth to take a stab at this. We can gradually enhance hooks later to support things like |
Ignore above commit. This fix is actually related to issue #333 |
Thank you for considering this enhancement! I've taken the initiative to contribute to this feature by creating a pull request. In my pull request, I've included an initial version of the proposed functionality. Your feedback on the implementation would be greatly appreciated. Pull Request: #366 |
@helloanoop do you think it would be possible to leverage |
@helloanoop Does it make sense to have two files Are you planning to add such bru file for folder level ? |
Additionally, this feature could also provide the ability to define a specific order or sequence for the directories, enhancing organization and accessibility within the UI. |
Hello, It's for me the killer feature that would make me switch definitely from Postman to Bruno. |
@giuseppemilicia @martinsefcik Yes. Folder/Directory level scripts, headers, auth etc are in the roadmap.
I don't have a strong reason on why need we need to have them separate. This evolved naturally. First there was |
@giuseppemilicia @vaurat We will support directory sequencing once we support for Meanwhile a temporary workaround is to prefix your folders with numbers |-collection
|- 1 - folder 1
|- 2 - folder 2
|- 3 - folder 3 I know its a pretty bad work around :P |
It appears to me that the collection post-response script executes before the request post-response script; e.g. some console.log output.... Starting collection pre-req script; Is it not more logical to have the collection post-response script run after the request post-response ? p.s. my first issue here, great app, looking forward to contributing more :-) |
@zDavidB Postman and Thunder Client do not have post-response scripts but have tests which can be considered the same as post-response scripts and the order is the same as in Bruno: Postman:
Thunder Client:
So I think to have it opposite as in other commonly used clients would be confusing. |
Good explanation thanks @martinsefcik |
Hi, I have been experimenting with collection pre-request and post-response scripts to have a cookie being picked up when running
It looks like collection.bru is mistakenly being picked up as a runnable request, which in turn has no URL, resulting in the host being The
Basically, the scripts in the post-response looks for a Here attached is a Proof of Concept to help reproduce the issue. To reproduce this: $ cd dev-integration/
$ npm install
$ npx bru run .
Running Folder
collection (getaddrinfo ENOTFOUND undefined)
1-setcookie (200 OK) - 279 ms
manually saving the cookie
2-getcookie (200 OK) - 137 ms
Requests: 2 passed, 1 failed, 3 total
Tests: 0 passed, 0 total
Assertions: 0 passed, 0 total I expected |
Closing this issue as Bruno now support collection level pre and post request scripts. |
I would like to propose the addition of a feature that allows users to define pre/post request scripts at the collection level in order to execute them before/after each call made within that collection. This would greatly enhance the flexibility and functionality of the platform.
Is it possible to consider implementing this feature in future updates? Thank you for your consideration.
Tasks
The text was updated successfully, but these errors were encountered: