gpt4 book ai didi

javascript - reactjs App.test.js 错误

转载 作者:搜寻专家 更新时间:2023-11-01 04:34:50 25 4
gpt4 key购买 nike

我在尝试为安装 reactjs 时获得的 App.test.js 运行 npm.test 时遇到此错误。关于如何解决这个问题的任何想法?我现在添加了一些额外的代码等。

> client@0.1.0 test /Users/filipmyllari/Documents/1DV430/fm222hp- 
project/client
react-scripts test --env=jsdom

>2018-05-29 16:26 node[535] (FSEvents.framework) FSEventStreamStart:
register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-05-29 16:26 node[535] (FSEvents.framework) FSEventStreamStart:
register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:182
throw er; // Unhandled 'error' event
^

>Error: Error watching file for changes: EMFILE
at _errnoException (util.js:1019:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1360:9)
npm ERR! Test failed. See above for more details.

这里是package.json文件

{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"add": "^2.0.6",
"babel-jest": "^23.0.1",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"firebase": "^4.13.1",
"jest": "^23.0.1",
"lodash": "^4.17.5",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"react-test-renderer": "^16.4.0",
"yarn": "^1.7.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"enzyme": "^3.3.0",
"react-addons-test-utils": "^15.6.2"
}
}

代码在下面(App.test.js)

import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
})

describe('Addition', () => {
it('knows that 2 and 2 make 4', () => {
expect(2 + 2).toBe(4);
});
});

最佳答案

这是使用 Jest 进行测试时的常见问题。

我建议您按照 Jest issue 1767 中的建议安装 watchman .

brew install watchman

安装后任何测试都应该没有问题,它已经解决了我和我的一些同事计算机上的此类问题,因此我相信它也值得您尝试。


此外,一些关于问题的最新回复建议更新 Jest 以忽略错误:

Ultimately, updating to Jest 23.1.0 resolved the issue. (releaf)

关于javascript - reactjs App.test.js 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50586974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com