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

request: Allow Mocking of Image.network #18

Closed
1 task done
ABausG opened this issue Mar 2, 2022 · 4 comments
Closed
1 task done

request: Allow Mocking of Image.network #18

ABausG opened this issue Mar 2, 2022 · 4 comments

Comments

@ABausG
Copy link
Contributor

ABausG commented Mar 2, 2022

Is there an existing feature request for this?

  • I have searched the existing issues.

Command

I would like to mock Image.network to support that in golden_tests

Description

I want to test widgets that use Image.network in golden tests. Right now if there is a widget trying to use Image.network the following exception is thrown:

When the exception was thrown, this was the stack:
#0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:98:9)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

Image provider: NetworkImage("", scale: 1.0)
Image key: NetworkImage("", scale: 1.0)

Reasoning

Testing widgets with Network Images should be vital

Additional context and comments

I tried to wrap the goldenTest with await mockNetworkImages(() async { from https://github.com/felangel/mocktail/tree/main/packages/mocktail_image_network but that did not have the desired effect

@Kirpal
Copy link
Collaborator

Kirpal commented Mar 2, 2022

Thanks for bringing this up! When you say "mock", do you mean you'd like to intercept the requests and add your own placeholder images? Or do you mean you'd like to match the implementation of mockNetworkImages, where the request succeeds but shows a 1-pixel transparent image?

@ABausG
Copy link
Contributor Author

ABausG commented Mar 2, 2022

Initially I thought Kirschsteines a system in place that makes the tests not fail would be nice, but thinking about what you said I think being able to provide custom placeholder would be even better.

@samandmoore
Copy link
Member

Is this in scope for this library or could it be facilitated by using a network image mocking package in conjunction with alchemist?

@ABausG
Copy link
Contributor Author

ABausG commented Mar 3, 2022

I think it would be better if people can use their preferred image mocking package with alchemist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants