You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I might be missing something here, but when bumping our TCA version and migrating to Sharing 2.0, some of our tests began to fail.
It appears that shared state changes from our teststore assertions bleed back into the reducer?
Here's a repro repo in the UserDefaults case studies
here's a pic of the test output. (Note, i'd expect a single failed action here, but getting 2. Adding a breakpoint reveals that the source of the second fire is the TestStore assertion closure.)
Checklist
I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
If possible, I've reproduced the issue using the main branch of this package.
here's a pic of the test output. (Note, i'd expect a single failed action here, but getting 2. Adding a breakpoint reveals that the source of the second fire is the TestStore assertion closure.)
Also, to "fix this", i can receive both publisher actions, but in our production app, the publisher fires off a chain of events that are asserted, so it would require receiving all of those duplicate actions.
private var value: Value {
willSet {
subject.send(newValue)
}
}
willSet is triggered when below state assertion made.
await store.send(.counter(.incrementButtonTapped)) { // first willSet is triggered as the result of action.
$0.counter.$count.withLock { $0 = 1 } // Second willSet is triggered, when we assert.
}
in TestStore.swift there is expectedStateShouldMatch method that applies mutation to the state. We might need to lose the reference to the Shared value while mutating expectedState not to trigger subject.send
Description
I might be missing something here, but when bumping our TCA version and migrating to Sharing 2.0, some of our tests began to fail.
It appears that shared state changes from our teststore assertions bleed back into the reducer?
Here's a repro repo in the UserDefaults case studies
here's a pic of the test output. (Note, i'd expect a single failed action here, but getting 2. Adding a breakpoint reveals that the source of the second fire is the TestStore assertion closure.)

Checklist
main
branch of this package.Expected behavior
TestStore changes to Shared State don't affect the Reducer body
Actual behavior
TestStore changes to Shared State affect the Reducer body
Reproducing project
https://github.com/JOyo246/swift-composable-architecture
The Composable Architecture version information
05601a7
Destination operating system
iOS 18.1
Xcode version information
Xcode 16.2
Swift Compiler version information
The text was updated successfully, but these errors were encountered: