zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 622 forks source link

Not able to Mock the Result of Query Widget #1408

Open Manik2708 opened 9 months ago

Manik2708 commented 9 months ago

Describe the issue This is related to the issue: https://github.com/PalisadoesFoundation/talawa/issues/1294, The file which is to be tested contains Query Widget which is not invoking the mock result.

To Reproduce (MUST BE PROVIDED) 1) Use Query widget in any of your project. 2) Try to write Unit Tests for it.

Screenshot from 2024-02-16 23-28-44 (This widget should be used)

3) Try to mock the behavior of GraphQL Client

Screenshot from 2024-02-16 23-38-46

Expected behavior inside calling should be printed! But it's not. This implies client.query is not being called. When went into this widget, got to know that it is using an independent method useQueryOnClient for fetching result. As this method is not wrapped under any class, it's not possible to mock it. Kindly make the methods of this widget ready for mocking. Would appreciate another method to test this widget (if exists)!

device / execution context Are you on iOS, android, web, in a simulator, running from the terminal etc? This is especially important for localhost connection issues.

Other useful/optional fields

Please fill or delete these sections if you don't fill them in

Stacktrace: ```dart {my stacktrace here} ```

screenshots Screenshot from 2024-02-16 23-28-20

additional context

additional notes Did you struggle to understand the docs or examples, or dislike the current api?

If you want to troubleshoot or discuss in real time, consider coming to the support channel in the discord