Jest test stuck on bitbucket pipelines without any error
Asked Answered
F

3

12

We use Bitbucket pipelines in our CI for testing, Our application is NestJS with Typescript tested with Jest.

We always got all tests running, however few days from now (2022 may) the tests are stuck after some suit, the suite where the test stuck is quite random.

The tests dont fail, we dont have any memory warning or anything else, it just is stucked on the pipeline. We need to stop the pipeline because it never stop.

Unfourtunately we dont any error for furgher investigation.

What could we do to inspect more details?

Fluttery answered 5/5, 2022 at 13:46 Comment(3)
Did you find a solution to this issue, we are facing the same problem.Siliqua
I realized that jest is taking too much memory and cpu now ( and I don't know why ) and I think that's why it's getting stucked on BitBucket Pipelines. Unfortunately I didn't find a solution.Venison
I didnt fixed it yet, but i'm running one test at time and it kind of "solve" the problema bit it takes 10 times the time into the pipelineFluttery
V
7

I was facing the same issue and I noticed that jest was consuming all the resources, so what worked for me was to set CPU usage limit during the tests using the following command:

jest --maxWorkers=20%

And I found this solution reading this amazing article here

Without this parameter, jest would consume all the resources of the docker machine on Bitbucket, potentially increasing runtime.

Venison answered 3/6, 2022 at 20:1 Comment(0)
S
3

Another solution that worked better for me than the above was to double the size of the build container. You will also get faster pipelines (albeit at marginally higher cost), so just do the tradeoff to see what works best in your case. You can double the size of the build container with the following size: 2x option in the bitbucket-pipelines.yml.

...
      - step
          name: Run Unit Tests
          image: node:14.17.0
          size: 2x
...

More info here: https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/

Spaceship answered 1/12, 2022 at 22:41 Comment(0)
R
2

You could try using the --runInband flag so you use one cache storage for all your tests instead of a cache per thread.

yarn jest --ci --runInBand

More details here

Radbun answered 1/12, 2022 at 23:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.