# How can I skip test at collection level for a specific request?

**URL:** <https://community.postman.com/t/how-can-i-skip-test-at-collection-level-for-a-specific-request/13477>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [June 17, 2020, 7:49pm UTC](https://community.postman.com/t/how-can-i-skip-test-at-collection-level-for-a-specific-request/13477 "2020-06-17T19:49:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nifepo](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nifepo](https://community.postman.com/u/nifepo)\
**Post date:** [June 17, 2020, 7:49pm UTC](https://community.postman.com/t/how-can-i-skip-test-at-collection-level-for-a-specific-request/13477/1 "2020-06-17T19:49:12Z")

</div>

I have this simple test at collection level

> ```
> tests["Status code is 200"] = responseCode.code === 200;
> 
> ```

It will work perfectly for every request on the collection except for negative tests (400/403/404 http code response).

So ideally, at request **Get Acommodation Type - 403** level I would like to write following test:

> ```
> pm.SkipCollectionTest
> tests["Status code is 200"] = responseCode.code === 403;
> 
> ```

Is this somehow possible? Thank you

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [June 17, 2020, 9:13pm UTC](https://community.postman.com/t/how-can-i-skip-test-at-collection-level-for-a-specific-request/13477/2 "2020-06-17T21:13:58Z")

</div>

Hey @nifepo

Welcome to the Postman community! 🏆

This kinda sounds like a question that’s been asked before - Would this solution help you to get closer to what you need:

> [@Skipping collection test but in the results it shows as skipped and failed](https://community.postman.com/t/skipping-collection-test-but-in-the-results-it-shows-as-skipped-and-failed/5438/6):
>
> No worries. Always happy to help. trophy Another, simpler way (credit to @singhsivcan for this slight_smile ) of looking for the status code and skipping the tests would be this: let skipTest = pm.response.code === 429; // Add this to the beginning of all the tests that need to be skipped when the status code is 429 // -\> (skipTest ? pm.test.skip : pm.test) // // For eg: (skipTest ? pm.test.skip : pm.test)("Check status code", () =\> { pm.response.to.be.su…

---

<div class="post-metadata">

**Author:** ![nifepo](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nifepo](https://community.postman.com/u/nifepo)\
**Post date:** [June 17, 2020, 11:29pm UTC](https://community.postman.com/t/how-can-i-skip-test-at-collection-level-for-a-specific-request/13477/3 "2020-06-17T23:29:08Z")

</div>

Hello, it helped but didn’t solve it. I couldn’t find a direct way of skilling a collection level test.

However, it made me think that I can do an if statement to expect 200 to every request that:

- Has **Prefer** header with **code=400**

![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/4/a46b7c05e1c44035f26145da591716b122cc5a8e.png)

Can you help me to write this test?

> pm.test(“Prefer header is present”, function () {
> 
> ```
> pm.request.to.have.header("Prefer")
> 
> ```
> 
> });

pm.request.to.have.header(“Prefer”) -------------\> It correctly validate the header exists, but I also need to validate the **REQUEST** header **VALUE**.

Any idea how to write it correctly?  
Thanks

---

<div class="post-metadata">

**Author:** ![nifepo](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nifepo](https://community.postman.com/u/nifepo)\
**Post date:** [June 18, 2020, 1:44am UTC](https://community.postman.com/t/how-can-i-skip-test-at-collection-level-for-a-specific-request/13477/4 "2020-06-18T01:44:04Z")

</div>

Solved.

I will add below code as an IF statement at collection level.

> pm.test(“Prefer header is present”, function () {
> 
> ```
> pm.request.to.have.header("Prefer", "code=400")
> 
> ```
> 
> });
