mockingjay icon indicating copy to clipboard operation
mockingjay copied to clipboard

Unable to work with routes using private types.

Open tomwyr opened this issue 1 year ago • 1 comments

It seems to be unable to mock navigator interactions when code in tests depends on types that are not publicly visible.

It's not uncommon that the Flutter SDK uses internal types that cannot be used outside the sdk. E.g. trying to test that DropdownButton pushes a dropdown menu will throw due to the when method generic type param that cannot be stubbed.

image

Attempting the above will fail with:

Exception has occurred.
TestFailure (No matching calls. All calls: MockNavigator.canPop(), MockNavigator.push<_DropdownRouteResult<String>>(_DropdownRoute<String>(RouteSettings(none, null), animation: null))

Mock navigator should expose a way of working around internal types (or maybe there already is one that I'm unaware of).

tomwyr avatar Feb 12 '24 12:02 tomwyr

Hi @tomwyr, can you share a minimal example to reproduce this issue?

robsonsilv4 avatar Jul 24 '24 20:07 robsonsilv4

Hi @tomwyr,

Is this still happening on your side? If so, would you mind sharing a minimal example as @robsonsilv4 suggested earlier? Otherwise, I might proceed with closing the issue.

Thanks for understanding!

omartinma avatar Sep 30 '25 07:09 omartinma

@omartinma Unfortunately, I don't have access to the codebase where I encountered this issue anymore but I'll try reproducing with it a minimal scenario and will let you know.

tomwyr avatar Sep 30 '25 09:09 tomwyr

@omartinma After looking into this again, I can't really remember what issue I encountered exactly.

  • If it was an error manifesting itself when running a test involving showing a dropdown menu, I don't seem to be able to reproduce it anymore.
  • If it was solely the inability to verify navigator interactions where private types are referenced (e.g., verify(() => navigator.push<_DropdownRouteResult>(any()))), I'm not sure if it should be considered this library's concern.

Please feel free to close this issue if you think there's nothing further that can be investigated by the team.

tomwyr avatar Sep 30 '25 14:09 tomwyr

Thanks for taking a look again @tomwyr, I will proceed closing the issue for now, but feel free to reopen it if you encounter this issue again.

omartinma avatar Oct 02 '25 11:10 omartinma