# Yarn test hangs when one more tests file is added

**URL:** <https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606>\
**Category:** Running Tests\
**Created:** [February 25, 2019, 8:35pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606 "2019-02-25T20:35:38Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 25, 2019, 8:35pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/1 "2019-02-25T20:35:38Z")

</div>

Hi All,

I’m running a project that has several test suites (Jest), all passing locally.  
I have a step in my CircleCI job that simply runs `yarn test`.

The problem is that the entire build hangs during the `yarn test` step. The tests all pass, but the step just hangs, and times out after 10 min.

![CircleCI](https://global.discourse-cdn.com/circleci/original/3X/e/4/e43c60614e2209d4650928191e7743c25e07d053.png)

To make thing more interesting, if I remove one test suite file from my tests folder, the step will pass. I can remove any tests file, it will still pass. That means there is nothing wrong with my tests. Also, if I remove one file, and add a new file with just one dummy test, the step will hang again.

What am I overlooking? (NOTE: using a free account)

Thanks!

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [February 26, 2019, 2:46pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/2 "2019-02-26T14:46:09Z")

</div>

That is strange. Are you running any browser tests? Those tend to hang in strange ways and can cause timeouts.

---

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 26, 2019, 3:52pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/3 "2019-02-26T15:52:50Z")

</div>

No, server side only.

But it will also consistently succeed until I add one more test file. And then consistently hang.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [February 26, 2019, 3:53pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/4 "2019-02-26T15:53:40Z")

</div>

And it doesn’t matter what the test is? It can be any test?

What about if you add a test and roll your cache keys? Any change?

---

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 26, 2019, 5:39pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/5 "2019-02-26T17:39:48Z")

</div>

I am not caching anything during this job.

And yes, it doesn’t matter what the test is. I tried right now adding a file named dummy.test.ts with this content:

`test('dummy', (done) => { done(); })`

and the build got stuck again. the build before passed.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [February 26, 2019, 5:40pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/6 "2019-02-26T17:40:45Z")

</div>

What happens if you try SSH’ing in, does it still hang? Does it give more details, or can you add more verbosity?

---

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 26, 2019, 5:43pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/7 "2019-02-26T17:43:18Z")

</div>

I had much more verbosity, which I suppressed.  
Tried running Jest with --detectOpenHandles. It just hangs, nothing happens.

I’d love some help trying to figure out how to troubleshoot via SSH.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [February 26, 2019, 5:45pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/8 "2019-02-26T17:45:06Z")

</div>

Sure, these steps [https://circleci.com/docs/2.0/ssh-access-jobs/](https://circleci.com/docs/2.0/ssh-access-jobs/) will walk you though how to SSH into the box. I would then suggest running the tests again to see where and how they hang.

---

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 26, 2019, 6:23pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/9 "2019-02-26T18:23:32Z")

</div>

Via SSH the tests pass 😕  
(I ran them 3 times, just to make sure).

When I ran ‘Rebuild with SSH’ I got this message during the tests (it wasn’t there before):  
`ENOMEM: not enough memory, read`

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [February 26, 2019, 6:27pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/10 "2019-02-26T18:27:57Z")

</div>

Hrm. Can you [open a ticket with the build URL](https://support.circleci.com/hc/en-us/requests/new)? I’d like to take a look and see if I can spot anything strange. Please ping me the ticket number.

---

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 26, 2019, 6:32pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/11 "2019-02-26T18:32:32Z")

</div>

Ticket #47071

---

<div class="post-metadata">

**Author:** ![besquared](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/besquared/32/21534_2.png) [@besquared](https://discuss.circleci.com/u/besquared)\
**Post date:** [February 27, 2019, 5:32am UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/12 "2019-02-27T05:32:27Z")

</div>

I’m seeing the same thing with yarn test and jest v24… It’s really intermittent and sometimes just restarting the build a few times will make it work… Not sure what’s going on either…

---

<div class="post-metadata">

**Author:** ![besquared](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/besquared/32/21534_2.png) [@besquared](https://discuss.circleci.com/u/besquared)\
**Post date:** [February 27, 2019, 5:49am UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/13 "2019-02-27T05:49:23Z")

</div>

Actually I think it’s related to the issue listed here [https://github.com/facebook/jest/issues/5239#issuecomment-355867359](https://github.com/facebook/jest/issues/5239#issuecomment-355867359)

adding --runInBand to your jest command will fix it and dramatically speed up your tests.

---

<div class="post-metadata">

**Author:** ![juvaly](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/juvaly/32/22017_2.png) [@juvaly](https://discuss.circleci.com/u/juvaly)\
**Post date:** [February 27, 2019, 6:40am UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/14 "2019-02-27T06:40:54Z")

</div>

For me the problem is very consistent. But I peeked at the github thread you linked, @besquared, and **setting -w=2 worked**!

Edit for future readers: setting -w=2 limits the number or worker Jest uses to 2. I assume this can be raised to more workers in paid account with stronger machines, but 2 works great for free accounts, which run machines with 2 cores.

---

<div class="post-metadata">

**Author:** ![besquared](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/besquared/32/21534_2.png) [@besquared](https://discuss.circleci.com/u/besquared)\
**Post date:** [February 27, 2019, 3:46pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/15 "2019-02-27T15:46:54Z")

</div>

For the record I found this solution in the CircleCI docs but just no in the place you’d expect… It was linked at the bottom of this article:

[https://circleci.com/docs/2.0/collect-test-data/#jest](https://circleci.com/docs/2.0/collect-test-data/#jest)

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [February 27, 2019, 3:48pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/16 "2019-02-27T15:48:58Z")

</div>

@besquared That’s good feedback. Our docs are open-source so PRs welcome, but where would be a better place to surface this information?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [March 9, 2019, 3:48pm UTC](https://discuss.circleci.com/t/yarn-test-hangs-when-one-more-tests-file-is-added/28606/17 "2019-03-09T15:48:58Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
