Reactjs 纱线测试失败-网络请求失败

Reactjs 纱线测试失败-网络请求失败,reactjs,jestjs,cloud9-ide,create-react-app,Reactjs,Jestjs,Cloud9 Ide,Create React App,我使用create react app创建了一个react项目,但是当运行warn test查看初始测试是否通过时 TypeError: Network request failed at XMLHttpRequest.xhr.onerror (/home/ubuntu/wonderland/hackernews/node_modules/whatwg-fetch/fetch.js:436:16) at XMLHttpRequest.callback.(anonymous fun

我使用
create react app
创建了一个react项目,但是当运行
warn test
查看初始测试是否通过时

TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (/home/ubuntu/wonderland/hackernews/node_modules/whatwg-fetch/fetch.js:436:16)
    at XMLHttpRequest.callback.(anonymous function) (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:289:32)
    at invokeEventListeners (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
    at invokeInlineListeners (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:166:7)
    at EventTargetImpl._dispatch (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:122:7)
    at EventTargetImpl.dispatchEvent (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
    at XMLHttpRequest.dispatchEvent (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
    at XMLHttpRequest.abort (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:405:16)
    at Object.abort (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:315:13)
    at RequestManager.close (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:146:21)
    at Window.close (/home/ubuntu/wonderland/hackernews/node_modules/jsdom/lib/jsdom/browser/Window.js:362:29)
    at JSDOMEnvironment.dispose (/home/ubuntu/wonderland/hackernews/node_modules/jest-environment-jsdom/build/index.js:44:19)
    at Promise.resolve.then (/home/ubuntu/wonderland/hackernews/node_modules/jest-cli/build/runTest.js:102:17)
我在Cloud9编辑器中工作,使用ssh连接到AWS中托管的开发服务器(Ubuntu)。测试在我的本地机器(Ubuntu)中运行良好


谢谢你的帮助

我已经解决了我的问题。我正在阅读一本书,书名为《学习反应之路》,我认为导致我出错的是我从外部API获取数据的部分。这本书忘了包含一个用于获取的导入,即:

import fetch from 'isomorphic-fetch'

然后,它像符咒一样解决了我的问题

它运行的是哪个版本的react脚本?我使用了react脚本的1.0.7版。我认为这是最新的版本。您是否能够从其他Cloud9项目ssh到您的服务器,或者这是唯一一个导致问题的项目?一切都很好。我可以用我的本地机器运行和启动我的应用程序,但当我运行测试时,它失败了。我想知道这是否是cloud9问题而不是react问题。您是否确认您的ssh具有正确的工作区配置?查看是否可以从另一个非反应cloud9工作区通过ssh连接到服务器将是一个快速发现问题的方法(或者,至少,它可能会给您提供更好的错误消息)。