[英]Enzyme decorated components TypeError: Cannot read property 'contextTypes' of undefined
I am testing a component decorated with JSCC with enzyme and jest, but I receive the following error: 我正在用酶和玩笑测试用JSCC装饰的组件,但是收到以下错误:
TypeError: Cannot read property 'contextTypes' of undefined
TypeError:无法读取未定义的属性“ contextTypes”
How to test this styled component? 如何测试这个样式化的组件?
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()) }) })
The component is decorated as: 该组件装饰为:
class PdfViewer extends React.Component{} ../ export default withStyles(styleSheet)(PdfViewer)
import { muiTheme } from 'material-ui/styles' const wrapper = shallow(<PdfViewer {...baseProps} />, { context: { muiTheme } })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.