Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking signals for unit/widget testing #106

Closed
biscottis opened this issue Jan 6, 2024 · 3 comments
Closed

Mocking signals for unit/widget testing #106

biscottis opened this issue Jan 6, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@biscottis
Copy link

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.

@rodydavis rodydavis added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 6, 2024
@rodydavis
Copy link
Owner

rodydavis commented Jan 8, 2024

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:

#104

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

@jinyus
Copy link
Contributor

jinyus commented Jan 8, 2024

@biscottis I just added testing with mocks for the shopping cart example. It uses the DI approach mentioned by @rodydavis

#110

@rodydavis
Copy link
Owner

Moving to a discussion, there are many approaches that can be done to test signals and excited to see what the community does!

Repository owner locked and limited conversation to collaborators Jan 9, 2024
@rodydavis rodydavis converted this issue into discussion #111 Jan 9, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants