Testing higher order reducer with jest
I have very minimal flow experience, but the action definition looks right. You may also be able to define a state type for this reducer.

It's pretty generic right now, so I'm not sure I would push it much more. Maybe it should be called fetchReducerFactory, just to keep the terminology consistent.

The tests look good. By "reliable", you probably mean "good." They are readable and look to provide good coverage for the code and branches.


You may want to test that the default state is correct.
You may want to test that unknown actions do nothing to the state.




NOTE: The following comment is pretty minor, but wanted to bring it up. The way the code is structured, the tests make sense. But there are implicit cases that work because of the code structure. Let me explain:

You expect FETCH_TEST_SUCCESS to do 3 things: (1) clear the isLoading flag (2) set data to the payload, and (3) set error to null. These three behaviors are wrapped together in one test. And, the only data that is actually changed by the reducer in this test is the data property; isLoading and error are not changed. So, for this test, you could make sure all values are changed by passing in a different state:

expect(
       factory({ data: null, isLoading: true, error: 3 }, 
               { type: "FETCH_TEST_SUCCESS", payload: "success" })
       ).toEqual({
         data: "success",
         isLoading: false,
         error: null
  });


This will guard against code changes later where someone refactors. Or, you could just have three small tests, each that test single property mutations. Again, small potatoes.