title: How do I mock the implementation of material-ui withStyles?
body: <p>How do I mock the implementation of <code>withStyles</code> in <code>material-ui/core/styles.js</code>?</p>
  
  <p>Here is the test:</p>
  
  <pre><code>import React from 'react'
  import { shallow } from 'enzyme'
  import { withStyles } from '@material-ui/core/styles'
  
  import TempComponent from './TempComponent'
  
  jest.mock('@material-ui/core')
  
  it('renders correctly', () =&gt; {
    const withStylesFake = styles =&gt;
      component =&gt; (
        component
      )
  
    withStyles.mockImplementation(withStylesFake)
  
    const wrapper = shallow(&lt;TempComponent /&gt;)
    expect(wrapper).toMatchSnapshot()
  })
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>import React from 'react'
  import { withStyles } from '@material-ui/core/styles'
  
  const TempComponent = () =&gt; (
    &lt;button&gt;Click Me!&lt;/button&gt;
  )
  
  export default withStyles({})(TempComponent)
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>TypeError: _styles.withStyles.mockImplementation is not a function
  
    at Object.&lt;anonymous&gt;.it (src/TempComponent.snapshot.test.js:15:22)
        at new Promise (&lt;anonymous&gt;)
    at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
        at &lt;anonymous&gt;
    at process._tickCallback (internal/process/next_tick.js:188:7)
  </code></pre>
  
  <p>This would work:</p>
  
  <pre><code>// ./__mocks__/@material-ui/core/styles
  export const withStyles = styles =&gt; (
    component =&gt; (
      component
    )
  ) 
  </code></pre>
  
  <p>but this is not local to the test.</p>