Which statement best describes the relationship between collections and folders in Postman?
Think about how you organize files on your computer into folders inside a main folder.
In Postman, a collection is a container for API requests. Folders help organize these requests inside the collection logically.
Given a Postman collection JSON with 3 folders, what will be the output of the following test script counting folders?
const folderCount = pm.collection.folders.count(); console.log(folderCount);
pm.collection.folders.count() returns the number of folders in the current collection.
The count() method on pm.collection.folders returns the total number of folders in the collection, which is 3 here.
Which assertion correctly verifies that a folder named 'User APIs' exists in the current Postman collection?
const folderNames = pm.collection.folders.all().map(folder => folder.name);Check if an array includes a specific string.
Using to.include checks if the array contains the folder name 'User APIs'. Other options are incorrect because they expect exact equality or wrong property checks.
Why does this Postman test script throw an error: TypeError: pm.collection.folders.map is not a function?
const folderNames = pm.collection.folders.all().map(folder => folder.name); pm.test('Check folders', () => pm.expect(folderNames.length).to.be.above(0));
Check the data type of pm.collection.folders before using array methods.
pm.collection.folders is a FolderList object, not a plain array. It does not support map() directly. You need to convert it to an array first using all() method.
For a large API project with hundreds of requests, which approach best uses Postman collections and folders to maintain test clarity and reusability?
Think about grouping related requests and sharing setup code efficiently.
Using folders inside a collection to group related requests allows better organization. Folder-level scripts help reuse setup and assertions, improving maintainability.