Bruno collections are stored as plain text files directly in your filesystem. Each collection is a folder containing .bru files for requests, environment files, and a bruno.json configuration file. This approach makes your API collections fully version-controllable and shareable.
The collection.bru file defines default settings applied to all requests in the collection.
collection.bru
headers { check: again token: {{collection_pre_var_token}} collection-header: collection-header-value}auth { mode: bearer}auth:bearer { token: {{bearer_auth_token}}}vars:pre-request { collection_pre_var: collection_pre_var_value collection_pre_var_token: {{request_pre_var_token}} collection-var: collection-var-value}script:pre-request { // Runs before every request in the collection const shouldTestCollectionScripts = bru.getVar('should-test-collection-scripts'); if(shouldTestCollectionScripts) { bru.setVar('collection-var-set-by-collection-script', 'collection-var-value-set-by-collection-script'); }}tests { // Runs after every request in the collection const shouldTestCollectionScripts = bru.getVar('should-test-collection-scripts'); const collectionVar = bru.getVar("collection-var-set-by-collection-script"); if (shouldTestCollectionScripts && collectionVar) { test("collection level test - should get the var that was set by the collection script", function() { expect(collectionVar).to.equal("collection-var-value-set-by-collection-script"); }); bru.setVar('collection-var-set-by-collection-script', null); bru.setVar('should-test-collection-scripts', null); }}docs { # bruno-testbench 🐶 This is a test collection that I am using to test various functionalities around bruno}
meta { name: js}headers { folder-header: folder-header-value}script:pre-request { // Runs before requests in this folder const shouldTestFolderScripts = bru.getVar('should-test-folder-scripts'); if(shouldTestFolderScripts) { bru.setVar('folder-var-set-by-folder-script', 'folder-var-value-set-by-folder-script'); }}tests { // Runs after requests in this folder const shouldTestFolderScripts = bru.getVar('should-test-folder-scripts'); const folderVar = bru.getVar("folder-var-set-by-folder-script"); if (shouldTestFolderScripts && folderVar) { test("folder level test - should get the var that was set by the folder script", function() { expect(folderVar).to.equal("folder-var-value-set-by-folder-script"); }); bru.setVar('folder-var-set-by-folder-script', null); bru.setVar('should-test-folder-scripts', null); }}
Folder-level settings are inherited by all requests within that folder. Request-level settings override folder settings, which override collection settings.