title: How do I use Jasmine to spy on a function that is imported via an ES6 default export?
body: <p>I am working on a Redux app &amp; trying to create a spy using Jasmine on an ES6 default exported function. I have attempted a few different ways of spying on the function, including using a wildcard import to access the 'default' property of the import, but nothing I've tried has worked thus far. Below is an example, where I would want to test <code>widgets.js</code> and spy on the widget function. Is there a way to achieve this without having to change the way im exporting the function from <code>widget.js</code>?</p>
  
  <p><strong>widget.js</strong></p>
  
  <pre><code>import { Map } from 'immutable';
  import { CREATE_WIDGET } from 'actions';
  
  const initialState = Map({
    id: undefined,
    name: undefined
  });
  
  export default function widget(state=initialState, action) {
    switch (action.type) {
      case CREATE_WIDGET:
        return state.update((widget) =&gt; widget.merge(action.widget));
  
      default:
        return state;
    }
  }
  </code></pre>
  
  <p><strong>widgets.js</strong></p>
  
  <pre><code>import { OrderedMap } from 'immutable';
  import { CREATE_ROOM } from 'actions';
  import widget from './widget';
  
  const initialState = OrderedMap();
  
  export default function widgets(state=initialState, action={}) {
    switch (action.type) {
      case CREATE_ROOM:
        return state.set(action.widget.id, widget(undefined, action));
  
      default:
        return state;
    }
  }
  </code></pre>