When you import a Postman collection into mabl, mabl ensures that different levels of pre- and post-request scripts are imported in the correct order. This article explains the differences between scripts in Postman and mabl and how Postman scripts are imported into mabl.
Postman scripts vs. mabl scripts
Postman and mabl both support running pre-request and post-request scripts:
- Pre-request scripts run before the request is executed.
- Post-request scripts, which are called test scripts in Postman, run after the request is executed.
The main difference between Postman scripts and mabl scripts is the number of script levels.
Postman supports adding scripts at the collection, folder, and request levels:
- Collection-level scripts apply to all requests in the Postman collection.
- Folder-level scripts apply to all requests that are immediate children of that folder. They do not apply to requests in nested folders.
- Request-level scripts apply to the individual request.
mabl supports adding scripts at the test and request level:
- Test-level scripts apply to every request in an API test.
- Request-level scripts apply to the individual request.
How Postman scripts are imported into mabl
To ensure that scripts in an imported Postman collection run in the correct order, mabl combines scripts differently depending on whether you import the collection as a single test or whether you import every folder as a separate test.
Importing as a single test
If you import an entire Postman collection as a single test, mabl makes the following updates to preserve the order of scripts:
- Collection-level scripts become one-time API snippets added at the test level so that they execute before every request in the test.
- Folder-level scripts become reusable API snippets and are prepended to every request that is an immediate child of that folder.
Importing as separate tests
If you import folders in a Postman collection as separate tests, each folder with at least one immediate child request becomes a new API test containing those same child requests. mabl makes the following updates to preserve the order of scripts:
- Collection-level scripts are saved as reusable snippets so that they can be reused across all imported API tests.
- Folder-level scripts are saved as one-time snippets.