Adding external libraries to postman

@yoelspotts You’ll first have to check if the library in question has a CDN equivalent that you can use. For instance, if you’d like to use strman, you can head over to it’s CDN link: https://cdnjs.cloudflare.com/ajax/libs/strman/1.3.1/strman.js, copy the contents over into the value of an environment variable, say strman_code. Next, you can include this within your code by adding the following snippet of code as the first statement in every request level pre-request/test script:

const strman_code = pm.environment.get('strman_code'); // strman_code now contains the library code

(new Function(strman_code))();

This will allow you to use strman functions within your collection run.

While the above example is specific to one library, the usage can easily be extended to just about any library that has a CDN equivalent. :smile:

4 Likes