Potential Breaking Change: Removing TestStore.scope
#1148
Replies: 4 comments 4 replies
-
Any scoped |
Beta Was this translation helpful? Give feedback.
-
I wonder what is the latest status on this, now that we seem to have new code for TestStore.scope, and have one less generic type parameters? |
Beta Was this translation helpful? Give feedback.
-
Late to the party here. We have >550 tests using using I will attempt to migrate these using a |
Beta Was this translation helpful? Give feedback.
-
I’ve come up with a good pattern for this that will allow us to update a lot of our tests without TOO MUCH thrash. Existing test:
Rewrite:
I found it WAY too heavy to add a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While
TestStore.scope
was an interesting experiment, and we utilized it in our Tic-Tac-Toe demo to test view state, there are a couple awkward things it introduces that make us think it should be on the chopping block:The feature makes
TestStore
a pretty intense type: it has five generics 😱swift-composable-architecture/Sources/ComposableArchitecture/TestSupport/TestStore.swift
Line 170 in b8dddaf
In general it's a lot to take in, and simplifying things would make the type more approachable.
Scoped test stores have an awkward matrix of what level you're at during an assertion:
send
Local
Local
receive
Global
Local
Received actions come from effects and not the view, so it doesn't make sense to receive view actions...but this mismatch is pretty trippy.
A cursory search on GitHub doesn't find much public use, but we were wondering if anyone following the repo takes advantage of this feature privately, and how heavily invested in it they may be.
There are a few alternate ways we find that folks test view state and actions:
Unit test them manually as data:
This is simple, but completely separated from reducer logic that produces the state in the first place, for better and/or worse.
Unit test them manually in an otherwise unscoped
TestStore
:This gives users the ability to get view state/action coverage in a normal
TestStore
test.Test using a view store, instead:
This focuses on the "view" aspect of this data, which means you lose test store affordances like testing exhaustivity and effects, but that might be how you want to focus on this aspect of testing.
Given the awkwardness of
TestStore.scope
and the availability of these less awkward alternatives, we think it's OK to deprecate, but would like to hear from you! We'll be rolling out an update soon with deprecation warnings in order to solicit more feedback (linking here).Beta Was this translation helpful? Give feedback.
All reactions