npm测试因使用create-react-app

时间:2016-12-06 15:43:08

标签: reactjs jestjs create-react-app

对于我在__test__文件夹中创建了一些与src

相同级别的测试

运行npm test项目文件夹后,我收到以下错误

如何解决这个问题,以便我可以运行测试?

jenkins@VBOX:dashboard$ npm test

> react-scripts test --env=jsdom
Determining test suites to run...fs.js:1236
    throw error;
    ^
Error: watch /home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/babel-jest/node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument/node_modules/babel-types/node_modules/babel-runtime/node_modules/core-js/fn/symbol ENOSPC
    at exports._errnoException (util.js:907:11)
    at FSWatcher.start (fs.js:1234:19)
    at Object.fs.watch (fs.js:1262:11)
    at NodeWatcher.watchdir (/home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/sane/src/node_watcher.js:144:20)
    at Walker.<anonymous> (/home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/sane/src/node_watcher.js:353:12)
    at emitTwo (events.js:87:13)
    at Walker.emit (events.js:172:7)
    at /home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/sane/node_modules/walker/lib/walker.js:69:16
    at go$readdir$cb (/home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/graceful-fs/graceful-fs.js:149:14)
    at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR! Test failed.  See above for more details.

3 个答案:

答案 0 :(得分:4)

Sometimes we hit the limit on the number of files we can watch simultaneously and we gains the error while having plenty of free space.

On Linux (Debian Wheezy, npm v3.10.10, node v6.10.2) it can be fixed by trying $ npm dedupe first, and, if still necessary, by

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Credits go to hexo.io.

答案 1 :(得分:1)

因此,在每个节点的第一行末尾的所有大写字母中出现无意义的单词错误...那是error code。这一个是ENOSPCwhich means "no space on drive"

即。您的驱动器已满,您必须在再次运行npm安装之前释放空间,而前者不是后者解决了您的问题。

答案 2 :(得分:0)

我遇到了完全相同的问题。我通过安装最新的npm来解决这个问题。我用npm版本2.15.11得到了ENOSPC错误。它适用于v3.10.10。