TestStore.send not asserting properly #1519
Replies: 3 comments 16 replies
-
It's hard to know what is going on without seeing some code. Can you share something that we can run locally to reproduce? The only guess I have without seeing more code is that perhaps you are using a reference type for your state? Reference types have instance/identity equality and are not equal based on just the data they hold. |
Beta Was this translation helpful? Give feedback.
-
Hi @mattdornfeld, I'm going to move this to a discussion because I do not believe it is a bug in the library considering we have a ton of test coverage on this area of the library and have never witnessed this before. If you are still having trouble please feel free to share some code so that we can help diagnose the problem. |
Beta Was this translation helpful? Give feedback.
-
Okay, I have the same issue I think, something really weird is going on. I can take this: @MainActor
class ToastsReducerTests: XCTestCase {
func testUndo() async {
let store = TestStore(
initialState: 1,
reducer: Reducer<Int, String, Void> { state, action, _ in
state += 1
return .none
},
environment: ()
)
_ = await store.send("yo") { _ in }
}
} And now - when I stick it into my project it's ✅ (incorrect), when I stick it into TCA sample project its 🚫 (correct). What the hell does that mean 😝? I know... It means that there is something specific to my (or our @mattdornfeld ) projects that really do not play well. But what's that 🤔🤔🤔? To make things even funnier - my current logic is 100% TDD - I swear it was working before 😅 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I'm running TCA 0.42.0. I'm trying to write tests for my reducer. To make sure things are functioning properly I'm trying to intentionally write a failing test. I followed the examples in the documentation and here is my minimum reproducing example
And here are the logs from running the test
Checklist
main
branch of this package.Expected behavior
I inserted the two log statements to confirm the state is updated correctly. Initially
shouldLoadCommentsPage
is false. I sent theloadCommentsPage
action and afterwards it's true. However I'm passing$0.shouldLoadCommentsPage = false
into with the closure that's passed tosend
. I expect this to make the test fail sinceshouldLoadCommentsPage
is updated to true. However the test seems to finish without any problems.Actual behavior
The test finishes without any errors.
Steps to reproduce
No response
The Composable Architecture version information
0.42.0
Destination operating system
ios 15
Xcode version information
XCode 14
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions