D
D
Denis_Lebedinsky2018-10-30 09:22:41
Software testing
Denis_Lebedinsky, 2018-10-30 09:22:41

How to test Redux saga with jest?

From the documentation, I did not understand how to test such sagas:

function* mySaga() {
    yield all([
        takeLatest(Types.FETCH_INFO_DISK_REQUEST, fetchDisk),
        takeLatest(Types.FETCH_RESOURCES_REQUEST, fetchResources),
        takeLatest(Types.DEL_FOLDER_REQUST, del_folder),
        takeLatest(Types.CREATE_FOLDER_REQUST, create_folder),
        takeLatest(Types.UPLOAD_FILE_REQUST, upload_file),
    ]);
}

Show an example or tell me where to find a detailed description

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Gerasimov, 2018-10-30
@Denis_Lebedinsky

const gen = mySaga();
const eff = gen.next().value;
expect(eff).toEqual(
  all([
    takeLatest(Types.FETCH_INFO_DISK_REQUEST, fetchDisk),
    takeLatest(Types.FETCH_RESOURCES_REQUEST, fetchResources),
    // ...
  ]),
);

You check that it is listened to, you test individual sagas separately

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question