Skipping a request, pre-request script and tests at the collection level

Is it possible based on some conditions (for example, the URL of the request includes “test”) write Pre-request script at the collection level to skip run of the pre-request script, the request and tests?

Example:
Request1 url includes “test”
Request2 url doesn’t include “test”
Request3 url includes “test”
Request4 url doesn’t include “test”

As a result in the collection run Request2 and Request4 are executed, Request1 and Request3 are not executed.

I’ve already tried:
Skip request based on condition (collection) - #3 by taehoshino with setting the request to
pm.request.url = ‘https://www.postman-echo.com/delay/0’;
pm.request.method = ‘GET’;
based on this condition, but it doesn’t help with pre-request script and tests.

I want to do it at the collection level to not repeat it in a lot of requests.

P.S. the condition to skip the test will be different.

Hi @katevolkova

See if this is of any use;

@w4dd325 it’s not really what I am looking for. In my collection I have a lot of requests that I want to skip based on some condition. So I want to do it on the collection level. I want to skip the request, its pre-request and tests. Let’s say the condition is to skip test if the method is DELETE (just for simplicity) and I don’t know how many such requests I have in my collection, so what do I need to write on the collection level?

You could alter this approach to your needs;

This will work, thank you @w4dd325. Hope in the future there will be a simpler solution.