我在我的整个应用程序中使用安装运行的酶试验。我想测试所有的孩子组件,所以相信这是最好的方法。我还将用其他测试测试各个组件。酶为什么没有测试反应高压力图?
我app.test.js如下:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import Store from '../../store';
import { shallow, mount } from 'enzyme';
const StoreInstance = Store();
it('renders without crashing',() => {
const div = document.createElement('div');
mount(
<Provider store={StoreInstance}>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>
);
});
,当我跑我的测试,我得到以下错误
console.error node_modules/react-dom/cjs/react-dom.development.js:8305
The above error occurred in the <HighchartsChart> component:
in HighchartsChart (at Graph.js:42)
in div (at Graph.js:41)
in div (at Graph.js:37)
in Graph (at Dashboard.js:39)
in div (at Card.js:24)
in div (at Card.js:10)
in Card (at Dashboard.js:38)
in div (at Dashboard.js:20)
in Dashboard (created by Route)
in Route (at App.js:59)
in Switch (at App.js:58)
in main (at App.js:57)
in div (at App.js:54)
in App (created by Connect(App))
in Connect(App) (created by Route)
in Route (created by withRouter(Connect(App)))
in withRouter(Connect(App)) (at App.test.js:17)
in Router (created by BrowserRouter)
in BrowserRouter (at App.test.js:16)
in Provider (created by WrapperComponent)
in WrapperComponent
Consider adding an error boundary to your tree to customize error handling behavior.
You can learn more about error boundaries at react docs (fb.me/react-error-boundaries).
它实际上并没有说是什么错误等等我正在努力调试。
我不知道它是抱怨<ReactHighcharts />
成分,我用我的graph.js其中:
class Graph extends Component {
render() {
return (
<div className="graph-container">
<div className="graph">
<ReactHighcharts config={this.props.config ? this.props.config : config} /> // config var is defined but I haven't included it
</div>
</div>
);
}
}
export default Graph;
希望得到任何帮助。
感谢
编辑:
我已经添加了错误的边界部分按照该建议,我现在越来越善于exports.name(/ node_modules/jsdom/lib中的跟随误差
InvalidCharacterError /jsdom/living/helpers/validate-names.js:10:11) at DocumentImpl.createElement(/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:686:5) at Document。的createElement(/node_modules/jsdom/lib/jsdom/living/generated/Document.js:92:5 9) at a.createElement(/node_modules/highcharts/highcharts.js:18:45) at init(/node_modules/highcharts/highcharts.js:95:411) at Object.createElement(/ node_modules/highcharts/highcharts .js:65:261) at Object.createElement(/node_modules/highcharts/highcharts.js:111:222) at Object.init(/node_modules/highcharts/highcharts.js:104:305) at Object.C (/node_modules/highcharts/highcharts.js:113:48) 在getContainer(/node_modules/highcharts/highcharts.js:259:80){componentStack:“在HighchartsChart \ N(在Graph.js:45)\ n的ErrorBoundary(在Graph.js:44)\ n的格(在Graph.js:43)\ n的格(在Graph.js:39)\ n的图形(在Dashboard.js:39)\ n的DIV(在Card.js:24)\ n的格(在Card.js:10)\ n的卡(在Dashboard.js:38)\ n的格(在Dashboard.js:20)\ n的仪表板(由Route创建)\ n在Route(在App.js:59)\ n在Switch(在App.js:58)\ n在main(在App.js:57)\ n在div(在App.js :连接(应用程序))创建的连接(应用程序)(由路由创建)\ n中的应用程序(由Connect(App)创建)\ n \ )(在App.test.js:17)\ n在Router(由BrowserRouter创建)\ n在BrowserRouter(在App.test.js:16)\ n在提供者(由WrapperComponent创建)\ n在WrapperComponent'}
感谢您的。将密切关注这些线程 – Stretch0