I'm trying to run playwright tests on Bitbuket pipeline but pipeline is getting stuck while test ran
Asked by Ameer sohail:

We are trying to configure, playwright browser tests on Bitbucket Pipeline as code is in same repo of Bitbucket.  
While running it on local with below commands its working fine and reports are also getting generated. In total 72 tests are running and report is generated.  
Below are the commands:  
- npm ci  
- npx playwright install --with-deps  
- npx playwright test  
- npx playwright show-report  

Whereas if I tried to run the same script using Bitbucket yaml file its getting stuck at - npx playwright test and after 2 to 3 tests it is getting stuck and then logs are also getting stuck, after 2 hours build is showing Exceeded build time limit of 120 minutes error.  

bitbucket-pipelines.yml   

image: mcr.microsoft.com/playwright:v1.42.0-jammy

pipelines:  
branches:  
main:  
- step:  
name: Playwright Tests  
caches:  
- node  
script:  
- npm ci  
- npx playwright install --with-deps  
- npx playwright test  
- npx playwright show-report

<br />

devops/PB-2448-Web_Automation-2:  
- step:  
name: Playwright Tests  
caches:  
- node  
script:  
- npm ci  
- npx playwright install --with-deps  
- npx playwright test  
- npx playwright show-report  

Ill be attaching Screenshots of Bitbucket pipeline for reference.  

Please help me on this, I got stuck here from a while.  
![Screenshot 2024-04-03 at 17.47.58.png](/t5/image/serverpage/image-id/316025i40AF4D551B395654/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 at 17.47.58.png")![Screenshot 2024-04-03 at 17.48.13.png](/t5/image/serverpage/image-id/316024i4139EF8CAC1F4901/image-size/large?v=v2&px=999 "Screenshot 2024-04-03 at 17.48.13.png")


Answers:
author: Patrik S
body: Hello [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) ,

thank you for reaching out to the Atlassian Community!

In order to isolate if the issue is with Bitbucket Pipelines environment, or with the image/code/dependencies you are using, I would suggest trying to run your build locally inside a docker container following the instructions of the below article:

* [Troubleshoot failed Bitbucket Pipelines locally with Docker](https://confluence.atlassian.com/bbkb/debug-failed-bitbucket-pipelines-locally-with-docker-1318882094.html?_cachebust=7459017238)

The instructions in that article are used to reproduce locally an environment as close as possible to Pipelines, so you can troubleshoot your build locally, and if the same behavior is reproduced locally, you can debug the build check different combinations or images/dependencies, and once you find one that works, you can update your bitbucket pipelines YML to match.

Thank you, [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) !

Patrik S

comments: author: Ameer sohail
body: Hello [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)   

<br />

Thanks for the reply tried with the process you shared above.  
If I tried with similar docker commands its throwing errors with 7 test cases are failed.  
`docker build --memory=1g --memory-swap=1g -t account/imageName:tag -f my.dockerfile .`  
`docker run -it --memory=4g --memory-swap=4g --memory-swappiness=0 --cpus=4 --entrypoint=/bin/bash account/imageName:tag`

<br />

Whereas if used docker commands without `--memory=1g --memory-swap=1g` in docker build and `--memory=4g --memory-swap=4g --memory-swappiness=0 --cpus=4 in docker run` its running all test cases successfully.  

docker build -t myaccount/qa-automation-image:latest -f my.dockerfile .  
docker run -it --entrypoint=/bin/bash myaccount/qa-automation-image

Attaching screenshots for both scenarios test cases failed and test cases passed successfully.  

By this please let me know what sort of changes I need to do.  

Note: In pipeline its not passing more than 5 to 7 cases and getting stuck![Screenshot 2024-04-22 at 11.32.53.png](https://community.atlassian.com/t5/image/serverpage/image-id/319784i80C25D57C54639CA/image-size/large?v=v2&px=999 "Screenshot 2024-04-22 at 11.32.53.png")![Screenshot 2024-04-22 at 11.28.14.png](https://community.atlassian.com/t5/image/serverpage/image-id/319785i2F991A3861E11F0A/image-size/large?v=v2&px=999 "Screenshot 2024-04-22 at 11.28.14.png")


author: Patrik S
body: Hello [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) ,

I noticed that after the test is completed, playwright waits for the user to press Ctrl+C to quit the log stream, but since the pipeline environment is non-interactive, I suspect this may be holding the pipeline to complete.

To avoid that, I would recommend setting the environment variable **CI=true** (see [Playwright- CI](https://playwright.dev/docs/ci) ) before executing the playwright command, as this should make it ignore the prompts for user input:

```
script:
  - export CI="true"
  - npm ci
  - npx playwright install --with-deps
  - npx playwright test
  - npx playwright show-report
```

Thank you, [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) !

Patrik S


author: Ameer sohail
body: Hello [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)   

Tried with suggestions you have shared above by adding **CI=true** , but still its getting stucked, attaching screenshot for your reference.  
![Screenshot 2024-05-07 at 11.23.00.png](https://community.atlassian.com/t5/image/serverpage/image-id/322233i58D47820B03149FC/image-size/large?v=v2&px=999 "Screenshot 2024-05-07 at 11.23.00.png")


author: Patrik S
body: Hello [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) ,

Thanks for executing that test. To rule out a possible memory allocation issue, could you increase that step to [size:2x](https://support.atlassian.com/bitbucket-cloud/docs/step-options/#Size), so it will get double the memory (8GB), and check if the builds also time out?

```
- step:
   size: 2x
   script:
     - <your build commands>
```


author: Ameer sohail
body: Hello [@Patrik S](/t5/user/viewprofilepage/user-id/4603309),  

Tried with increasing size:2x, still same issue.  
![Screenshot 2024-05-08 at 15.39.16.png](https://community.atlassian.com/t5/image/serverpage/image-id/322587i99D4B10BB0FD3D9F/image-size/large?v=v2&px=999 "Screenshot 2024-05-08 at 15.39.16.png")![Screenshot 2024-05-08 at 15.41.49.png](https://community.atlassian.com/t5/image/serverpage/image-id/322588i3188A45C43B07147/image-size/large?v=v2&px=999 "Screenshot 2024-05-08 at 15.41.49.png")


author: Patrik S
body: Hello [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) ,

Thank you for going through those tests.

At this point, I've raised a support ticket for you to investigate this further, as you have access to a workspace with an active Bitbucket subscription. One of our support engineers will be in touch with you soon.

You will receive the ticket link in your email soon, but in case you don't, please let me know so I can share it here (the ticket will only be visible to you and Atlassian staff).

Thank you, [@Ameer sohail](/t5/user/viewprofilepage/user-id/5394437) !

Patrik S


Tags: bitbucket-cloud

cloud