Skip to content
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

docs: Tab UI Widget Test #4312

Closed
jensencelestial opened this issue Jan 3, 2025 · 1 comment
Closed

docs: Tab UI Widget Test #4312

jensencelestial opened this issue Jan 3, 2025 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@jensencelestial
Copy link

Description

Is there any documentation on how to create Widget Tests for Tab UI? Found this TODOs Doc that has 2 "tabs", each tab has its own BlocProvider. Can we create a Widget Test for HomeView that properly renders the IndexedStack? I don't know if there's any way we can mock/stub a BlocProvider.

Also found this which uses TabBar and also uses BlocProvider for each tab, but no Widget Tests.

@jensencelestial jensencelestial added the documentation Documentation requested label Jan 3, 2025
@felangel
Copy link
Owner

I recommend decomposing your widgets into "container" widgets which provide the necessary dependencies (e.g. BlocProviders) and "presentation" widgets which just render UI. This way you can test the presentation widgets by wrapping them in your own BlocProvider in the test which provides a mock bloc instance.

Hope that helps! 👍

@felangel felangel added question Further information is requested and removed documentation Documentation requested labels Jan 12, 2025
@felangel felangel self-assigned this Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants