2017-10-21 17 views
0

のプロパティ「contextTypes」を読み取ることができません私は、酵素と冗談でJSCCで飾らコンポーネントをテストしていますが、私は次のエラーが表示されます酵素は、コンポーネントのTypeError例外を飾っ:未定義

TypeError: Cannot read property 'contextTypes' of undefined

このスタイルのコンポーネントをテストするためにどのように?

import React from 'react' 
 
import { shallow } from 'enzyme' 
 
import { PdfViewer } from './PdfViewer' 
 

 
const baseProps = { 
 
    location: 'url', 
 
    defaultPage: 1, 
 
    classes: {}, 
 
    handlePageChanged:() => {}, 
 
} 
 

 
describe('<PdfViewer />',() => { 
 
    it('should work',() => { 
 
    const wrapper = shallow(<PdfViewer {...baseProps} />) 
 
    console.log(wrapper.debug()) 
 
    }) 
 
})

成分は、以下のように飾られている:

​​

答えて

0

import { muiTheme } from 'material-ui/styles' 
 
const wrapper = shallow(<PdfViewer {...baseProps} />, { context: { muiTheme } })

関連する問題