can moxios catch request from click event?

This issue has been tracked since 2018-12-14.

when i use redux, and i click a button, call a action, in action, a instance of axios was called, code like this

beforeEach(() => {
    moxios.install(instance);
    store = configureStore(initialStore)
    wrapper = Enzyme.mount(
        <Provider store={store}>
            <AppInput onChange={updateAppInfo}/>
        </Provider>
    )
})
it('updateAppInfo', (done) => {
        moxios.stubRequest('/app/get', {
            status: 200,
            responseText: 'hello'
        })
        wrapper.find('.xj-appinput-item').at(0).simulate('click');
        
        moxios.wait(() => {
            let request = moxios.requests.mostRecent();
            request.respondWith({
                status: 200,
                response: { a: 22 }
            }).then(() => {
            });
        });
    })

updateAppInfo function send a request which url is /app/get,
and as expect, moxios will catch this request,
but i got this error,
TypeError: Cannot read property 'respondWith' of undefined
so i wonder how to fix this?

z2014 wrote this answer on 2018-12-14

ok,i got it.you should call dispatch

More Details About Repo
Owner Name axios
Repo Name moxios
Full Name axios/moxios
Language JavaScript
Created Date 2016-05-25
Updated Date 2022-12-05
Star Count 1386
Watcher Count 20
Fork Count 85
Issue Count 19

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date