React Native + Jest EMFILE: too many open files error

感情迁移 提交于 2019-12-05 05:15:44

Short answer: adding 'ulimit -n 4096' to ~.bash_profile and opening a new terminal window resolved my issue.

The answer had to do with me not setting the ulimit properly.

sudo ulimit -n 10240

on my Mac silently doesn't change the ulimit. I had originally thought it was not doing anything because 10240 is not an increment of 1024. But it also didn't do anything when I tried 2048, 4096, etc.

So, what is "the" solution?

  • ulimit -n (without a number) will tell you what the current value is
  • for me, typing sudo ulimit -n 2048 in a terminal window did NOT change the ulimit (no matter what number I tried)
  • adding 'ulimit -n 4096' to ~.bash_profile and opening a new terminal solved the problem

I'm running windows in powershell. Also used Git Bash and had similar problems. I updated my package.json as follows:

  "devDependencies": {
    "jest-cli": "^0.8.2",
  },
  "jest": {
    "testPathDirs": ["__tests__"],
    "testPathIgnorePatterns": [
      "/node_modules/"
    ]
  },
  "scripts": {
    "test": "jest"
  },

Note that "testPathDirs": ["__tests__"], is the directory I place all my tests in.

Now I can run npm test without an issue. Ultimately it seems Jest is navigating the /node_modules/ directory which should be excluded.

I had a similar issue some time ago but couldn't figure out why jest was not ignoring my node_modules folder.

What I ended up doing is changing "testFileExtensions" from ["js"] to ["spec.js"] and renaming all the tests with the extension .spec.js

Not the proper solution but gives me time until seeing if new versions of jest fix this issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!