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

PropertyDescription
openApiOperationIdOpenAPI operationId.
openApiOperationIdsArray of operationIds.
openApiOperationMethod and path, supports wildcards.
excludeForOperationsOptional. Operations to skip.
testsArray of Postman test scripts. A value is either the script content or a path to a script file with the file: prefix.
overwriteDefault false. Removes all generated tests and replaces them with the tests array.
appendDefault 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.