title: React - jest test returns API token error
body: <p>I have the following test, but I get the following error: "API: unable to fetch api token." I tried using <code>shallow</code> instead of <code>mount</code> but it returns the same error.</p>
  
  <pre><code>describe('CreateTemplateModal', () =&gt; {
    let props, el
    const modal = function () {
      if (!el) el = mount(&lt;CreateTemplateModal {...props} /&gt;)
      return el
    }
  
    beforeEach(() =&gt; {
      props = {
        onSubmit: jest.fn().mockReturnValue(Promise.resolve()),
      }
      el = undefined
    })
  
    it('calls onSubmit when create template button is clicked', () =&gt; {
      const el = modal().setState({
        title: 'new template',
        jurisdiction: 'nsw',
        description: 'random',
      })
      el.find('#create-template-btn').simulate('submit')
      expect(props.onSubmit).toHaveBeenCalled()
    })
  })
  </code></pre>