-
Hi! I think signals is a criminally underrated state management framework, love it so far. It's a lightweight version of MobX, GetX without codegen and feels performant so far. I have a question, how can I mock signals for widget testing? If that makes any sense. I want to test screens or widgets given a certain 'state', for example in classic Bloc/Cubit you would have https://pub.dev/packages/bloc_test. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
In my tests I do a couple different things. If it is global I update the value in tests or override if the global is late or final. I also can define signals in classes and pass them in via DI. For testing it's just like other unit and widget tests. There is a draft PR for possibly using checks for this too: I think the question might imply more of a tracked signal in tests like testing the stream values and I think that would be possible with a signals observer |
Beta Was this translation helpful? Give feedback.
-
@biscottis I just added testing with mocks for the shopping cart example. It uses the DI approach mentioned by @rodydavis |
Beta Was this translation helpful? Give feedback.
-
Moving to a discussion, there are many approaches that can be done to test signals and excited to see what the community does! |
Beta Was this translation helpful? Give feedback.
@biscottis I just added testing with mocks for the shopping cart example. It uses the DI approach mentioned by @rodydavis
#110