How to pass context down to the Enzyme mount method to test component which includes Material UI component?
<p>I am trying to use <code>mount</code> from Enzyme to test my component in which a several Material UI component are nested. I get this error when running the test:</p>

<p><code>TypeError: Cannot read property 'prepareStyles' of undefined</code></p>

<p>After some digging, <a href="https://github.com/callemall/material-ui/issues/4021">I did found that a theme needs to be passed down in a context</a>. I am doing that in the test but still get this error. </p>

<p>My test:</p>

<pre><code>import expect from  'expect';
import React, {PropTypes} from 'react';
import {mount} from 'enzyme';
import SearchBar from './SearchBar';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

function setup() {
  const muiTheme = getMuiTheme();

  const props = {
    closeSearchBar: () =&gt; {},
    fetchSearchData: () =&gt; {},
    data: [],
    searching: false
  };

  return mount(&lt;SearchBar {...props} /&gt;, {context: {muiTheme}});
}

describe('SearchBar Component', ()=&gt; {

  it('Renders search toolbar properly', () =&gt; {
    const wrapper = setup();
    expect(wrapper.find('.toolbar').length).toBe(1);
    expect(wrapper.find('button').length).toBe(1);
  });
});
</code></pre>

<p>My searchbar component is a stateless component, so I am not pulling in any context. But even when I am, I still get the same error. </p>

<p>What am I doing wrong?</p>