酶的装饰组件类型错误:无法读取属性“contextTypes”的未定义
问题描述:
我测试饰JSCC与酶和玩笑的成分,但我收到以下错误:酶的装饰组件类型错误:无法读取属性“contextTypes”的未定义
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())
})
})
组件被装饰为:
答
import { muiTheme } from 'material-ui/styles'
const wrapper = shallow(<PdfViewer {...baseProps} />, { context: { muiTheme } })