Testing fireAndForget effect #1308
-
Hey! I use version 0.39.1 with the Effects on Publishers. I have a reducer which is responsible for saviging data to file:
This reducer reacts on every action and it is combined with main logic reducer. I want to test only main logic reducer without taking into account workoutPlansListSaveReducer's Effect, and I obviously receive "An effect returned for this action is still running." error. So, I have to append Is there a smarter way to make test passed (without just advancing scheduler) ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Just pass you main reducer to the test store instead of passing the merged reducers |
Beta Was this translation helpful? Give feedback.
-
Have you tried using an func testImmediateDebounce() async {
enum Action { case tap }
let store = TestStore(
initialState: 0,
reducer: Reducer<Int, Action, Void> { state, action, _ in
return .fireAndForget {
}
.debounce(id: 1, for: 1, scheduler: DispatchQueue.immediate)
},
environment: ()
)
await store.send(.tap)
} |
Beta Was this translation helpful? Give feedback.
Have you tried using an
immediate
scheduler for theremainQueue
during tests? For example, this test passes: