Running collection within collection

Hi all,

This might be a newbie question, so forgive my foolishness. However I’ve searched throught the forums and couldn’t find the answer.

I have a collection of tests (A) which tests some part of API and returns some data. Let’s call it “shared one”.
I have another collection (B) which depends on data returned by A.
I have one more collection (C) which also depends on data returned by A.

What I want to achieve is some sort of collection grouping.
I run C, which runs A first.
I run B, which runs A first.

Of course, I could just add all the tests from A to every other collection, however, I would have to make any change of tests in shared collection in other collections too, al the time… yuck.

Tried to find a solution using loading the collection file using the fs module. Not supported :frowning:

I’ll appreciate any idea, Thanks a lot.

Hey @danielcd
Welcome to the Postman community.
It sounds like you want to use “postman.sendNextRequest()” to control your workflow.
There is no “run this collection as a pre-requisite” in Postman but I’m doing exactly what you’re wanting in my workspace.

https://learning.getpostman.com/docs/postman/collection_runs/building_workflows/

I’ve posted about this quite a bit in the forum:

And here’s my talk at this year’s PostCon where I specifically talk about this:

Hi @postman-paul540, thank you for the advice.
I’ve already checked the setNextRequest(), however the internal logic of the calling of the requests would be insane. There is an API with a serious number of endpoints and I just can’t keep requests for each of them all in one huge collection.
Each of the collection must start with some tricky login sequence and that’s why I wanted to share this piece of code between collections.

I’m thinking about going up one level and write some commandline script, which will contain separate newman runs, each for one collection. However I have to solve the passing the output data out of the Postman, which is gonna be tricky again.

I have discovered this Postman Collection SDK which seems to do exactly what I need.
http://www.postmanlabs.com/postman-collection/
However, it doesn’t seem to work. Postman fails on " fs.readFileSync is not a function".

What node venison are you using?
Can you post the whole error?

$ node -v
v8.10.0

$ npm info postman-collection
dist-tags:
beta: 3.5.4-beta.1 latest: 3.5.4

The error comes from Postman

There was an error in evaluating the Pre-request Script: TypeError: fs.readFileSync is not a function

Console says

TypeError | fs.readFileSync is not a function