我正在使用酶和jest测试用JSCC修饰的组件,但是我收到以下错误:
TypeError:无法读取属性' contextTypes'未定义的
如何测试这个样式组件?
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())
})
})
&#13;
组件装饰为:
class PdfViewer extends React.Component{}
../
export default withStyles(styleSheet)(PdfViewer)
&#13;
答案 0 :(得分:0)
import { muiTheme } from 'material-ui/styles'
const wrapper = shallow(<PdfViewer {...baseProps} />, { context: { muiTheme } })