Writing tests using the withExhaustivity()
function does not work on TestStore
using the ReducerProtocol
#2391
LudvigIversen
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Hi @LudvigIversen, there definitely is a chance that we have overlooked something in our implementation of exhaustivity checking in the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When writing tests in our project we have found that we would like to use the
withExhaustivity()
function documented here; https://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/teststore/withexhaustivity(_:operation:)-9psu7We want to do this because we don't want to turn off exhaustivity for our whole
TestStore
when doing tests, instead only for specific actions. Consider the following example:Here I would like to be able to use the
withExhaustivity()
operation on thereceive
like this;The
.refresh
action received in this case calls further to other actions but they are not of interest for this specific tests since this focuses only on the.updateFilterBy()
action.However, this does not seem to work as of right now. To use exhaustivity in this test we would need to turn of exhaustivity for the entire test using
store.exhaustivity = .off
this is not ideal.What if we change how the
.updateFilterBy()
action works, making it do additional state-changes? Usingstore.exhaustivity = .off
will make it so that the test won't fail, just giving us an additional warning messages that there are changes that we have not asserted. This is something easily missed.What we can see is that this functionality works on a
TestStore
that tests a feature that uses thereducer
function, instead of theReducerProtocol
. This would work fine for example;As you can see, this test uses both the
reducer
as a function, as well as anenvironment
.My point is, or what I am asking, is that if there are any plans to make the
withExhaustivity()
function work onTestStore
that tests on features using theReducerProtocol
? And if it should work, what are the things that we might be doing wrong/missing?Beta Was this translation helpful? Give feedback.
All reactions