# How to auto-reject pull requests and merge if a unit test has failed

**URL:** <https://community.developer.atlassian.com/t/how-to-auto-reject-pull-requests-and-merge-if-a-unit-test-has-failed/80983>\
**Category:** Bitbucket Cloud\
**Tags:** testing, automated-testing, angular, forge\
**Created:** [June 19, 2024, 3:03pm UTC](https://community.developer.atlassian.com/t/how-to-auto-reject-pull-requests-and-merge-if-a-unit-test-has-failed/80983 "2024-06-19T15:03:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oiadsoijdq](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@oiadsoijdq](https://community.developer.atlassian.com/u/oiadsoijdq)\
**Post date:** [June 19, 2024, 3:03pm UTC](https://community.developer.atlassian.com/t/how-to-auto-reject-pull-requests-and-merge-if-a-unit-test-has-failed/80983/1 "2024-06-19T15:03:57Z")

</div>

I have an angular project that is tested with karma and jasmine. How to auto-reject pull requests and merge if a unit test has failed. Can i use a forge app for this task? Are there any tutorials i can follow?

---

<div class="post-metadata">

**Author:** ![ibuchanan](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/ibuchanan/32/35815_2.png) [@ibuchanan](https://community.developer.atlassian.com/u/ibuchanan)\
**Post date:** [June 19, 2024, 4:13pm UTC](https://community.developer.atlassian.com/t/how-to-auto-reject-pull-requests-and-merge-if-a-unit-test-has-failed/80983/2 "2024-06-19T16:13:02Z")

</div>

Welcome to the Atlassian developer community @oiadsoijdq,

There’s a user community post that describes how you might accomplish this with Bitbucket Pipelines:

> **[Can a pull request be automatically declined if the build fails ?](https://community.atlassian.com/t5/Bitbucket-questions/Can-a-pull-request-be-automatically-declined-if-the-build-fails/qaq-p/2149067)**
>
> Whenever a build fails, the associated pull request should be automatically rejected. Is there any setting for that?

More recently, Bitbucket Cloud has launched a feature to use Forge to build custom merge checks:

> **[Custom Merge Checks in Bitbucket Cloud - Bitbucket](https://bitbucket.org/blog/beta-custom-merge-checks-in-bitbucket-cloud)**
>
> Custom Merge Checks in Bitbucket Cloud, Powered by Forge, enables customers to add custom business logic as part of the Pull Request workflow.

---

<div class="post-metadata">

**Author:** ![oiadsoijdq](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@oiadsoijdq](https://community.developer.atlassian.com/u/oiadsoijdq)\
**Post date:** [June 20, 2024, 8:10am UTC](https://community.developer.atlassian.com/t/how-to-auto-reject-pull-requests-and-merge-if-a-unit-test-has-failed/80983/3 "2024-06-20T08:10:45Z")

</div>

I already read those and they don’t help much. How do i run the test script for the project and how do i get its results in the forge app and if it is even possible.
