jest

解决jest的”too many open files, watch”问题(Mac OSX)

在对一个有一定规模的react前端项目执行jest单元测试时,遇到了如下问题:

node scripts/test.js –env=jsdom
2020-02-04 11:05 node9117 FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2020-02-04 11:05 node9117 FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2020-02-04 11:05 node9117 FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:174
throw er; // Unhandled ‘error’ event
^
Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:123:28)
Emitted ‘error’ event at:
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:129:12)
npm ERR! Test failed. See above for more details.

错误信息
继续阅读…