2017-10-12 65 views
0

我在我的整個應用程序中使用安裝運行的酶試驗。我想測試所有的孩子組件,所以相信這是最好的方法。我還將用其他測試測試各個組件。酶爲什麼沒有測試反應高壓力圖?

我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'}

回答