Configuration
Extend tests
Add your own Postman test scripts to generated requests with Portman extendTests, inline or from files, appended or prepended.
extendTests adds your own raw Postman test scripts to targeted requests, for checks Portman cannot generate from the spec. You can append them to the generated tests, prepend them, or replace the generated tests entirely.
Example
json
{ "version": 1.0, "tests": { "extendTests": [ { "openApiOperationId": "leadsAll", "tests": [ "pm.test('say hello Portman', function(){ \n console.log('Hello Portman')\n});" ] } ] }}Options
| Property | Description |
|---|---|
openApiOperationId | OpenAPI operationId. |
openApiOperationIds | Array of operationIds. |
openApiOperation | Method and path, supports wildcards. |
excludeForOperations | Optional. Operations to skip. |
tests | Array of Postman test scripts. A value is either the script content or a path to a script file with the file: prefix. |
overwrite | Default false. Removes all generated tests and replaces them with the tests array. |
append | Default true. Place the tests after (true) or before (false) the generated tests. |
Loading scripts from files
json
"extendTests": [ { "openApiOperation": "GET::/crm/leads", "tests": ["file:./tests/leads-list.js"] }]In variations
extendTests can also be used inside a variation, under tests.extendTests, without a target.
For tests that should run after every request, use collectionTestScripts in globals.