我目前在尝试使用 jest 添加简单的单元测试时遇到问题。它不断抛出 TypeError:Component is not a function 错误,我无法修复它。有人以前遇到过同样的错误,或者有人对如何修复它有任何想法吗?真的很感激!
\n\n我从 jest 得到的测试结果如下:
\n\nUsing Jest CLI v11.0.2, jasmine2, babel-jest\nRunning 1 test suite...Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).\n FAIL app/views/connections/__tests__/Connections-test.js (3.217s)\nConnections\n \xe2\x9c\x95 it should return View\n\nConnections \xe2\x80\xba it should return View\n - TypeError: Component is not a function\n at ShallowComponentWrapper._constructComponentWithoutOwner (node_modules/react/lib/ReactCompositeComponent.js:250:8)\n at ShallowComponentWrapper.mountComponent (node_modules/react/lib/ReactCompositeComponent.js:159:15)\n at ShallowComponentWrapper.wrapper [as mountComponent] (node_modules/react/lib/ReactPerf.js:66:13)\n at ReactShallowRenderer._render …Run Code Online (Sandbox Code Playgroud)