1
votes

I am testing a component decorated with JSCC with enzyme and jest, but I receive the following error:

TypeError: Cannot read property 'contextTypes' of undefined

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)
1

1 Answers

0
votes

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