setState value used in componentDidMount is not reflected in Enzyme test
<p><strong>Component.js</strong></p>

<pre><code>import React from 'react'
import request from 'superagent'

export default React.createClass({
    getInitialState() {
        return {cats: []}
    },

    componentDidMount() {
        request('/api', (err, res) =&gt; {
            if (err) return;
            this.setState({
                cats: res.body.results
            })
        })
    },

    render() {
        let cats = this.state.cats
        let catsList = (
            &lt;ul&gt;
                {cats.map((c) =&gt; &lt;li key={c.id}&gt;cat&lt;/li&gt;)}
            &lt;/ul&gt;
        )
        return (
            &lt;div&gt;
                {cats.length ? catsList : null}
            &lt;/div&gt;
        )
    }
})
</code></pre>

<p><strong>Component.test.js</strong></p>

<pre><code>jest.unmock('../app.js')
jest.unmock('superagent')

import React from 'react'
import {mount} from 'enzyme'
import nock from 'nock'
import App from '../app.js'

describe('App', () =&gt; {
    let ajaxFn
    beforeEach(() =&gt; {
        ajaxFn = nock('http://localhost')
            .get('/api')
            .reply(200, {
                results: [{id: 1}, {id: 2}, {id: 3}]
            })
    })

    it('renders correct number of cats', () =&gt; {
        let wrapper = mount(&lt;App /&gt;)
        expect(wrapper.state('cats').length).toBe(3)
    })
})
</code></pre>

<p>The test does not pass. <code>wrapper.state('cats').length</code> is always <code>0</code>.</p>

<p>I understand that <code>setState</code> doesn't guarantee to update state immediately,
however if I log 'cats' in the component, I can see it updating.</p>