{"id":15489060,"url":"https://github.com/roughike/image_test_utils","last_synced_at":"2025-04-22T18:17:50.537Z","repository":{"id":50230602,"uuid":"148843526","full_name":"roughike/image_test_utils","owner":"roughike","description":"Provide mocked responses for Image.network widgets in Flutter widget tests.","archived":false,"fork":false,"pushed_at":"2021-07-07T09:05:02.000Z","size":30,"stargazers_count":41,"open_issues_count":8,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T16:21:53.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roughike.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-14T21:27:35.000Z","updated_at":"2025-01-09T17:47:18.000Z","dependencies_parsed_at":"2022-08-17T16:06:00.191Z","dependency_job_id":null,"html_url":"https://github.com/roughike/image_test_utils","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fimage_test_utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fimage_test_utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fimage_test_utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fimage_test_utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roughike","download_url":"https://codeload.github.com/roughike/image_test_utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250296275,"owners_count":21407037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T07:03:21.644Z","updated_at":"2025-04-22T18:17:50.498Z","avatar_url":"https://github.com/roughike.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# image_test_utils\n\n[![pub package](https://img.shields.io/pub/v/image_test_utils.svg)](https://pub.dartlang.org/packages/image_test_utils)\n [![Build Status](https://travis-ci.org/roughike/image_test_utils.svg?branch=master)](https://travis-ci.org/roughike/image_test_utils) \n\nWithout providing mocked responses, any widget test that pumps up `Image.network` widgets will crash.\n\n[There's a blog post that goes more into detail on this.](https://iirokrankka.com/2018/09/16/image-network-widget-tests/)\n\nCopy-pasting [the code for mocking the image responses](https://github.com/flutter/flutter/blob/master/dev/manual_tests/test/mock_image_http.dart) to every new project gets a little boring. This helper library makes it easier to provide those mocked image responses.\n\n## Usage\n\nFirst, depend on the library:\n\n**pubspec.yaml**\n\n```yaml\ndev_dependencies:\n  image_test_utils: ^1.0.0\n```\n\nNote that this library should be included in your `dev_dependencies` block; **not in your regular `dependencies`**.\n\nIn your widget tests, import the library and wrap your widget test in a `provideMockedNetworkImages` method.\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:flutter_test/flutter_test.dart';\nimport 'package:image_test_utils/image_test_utils.dart';\n\nvoid main() {\n  testWidgets('should not crash', (WidgetTester tester) async {\n    provideMockedNetworkImages(() async {\n      /// Now we can pump NetworkImages without crashing our tests. Yay!\n      await tester.pumpWidget(\n        MaterialApp(\n          home: Image.network('https://example.com/image.png'),\n        ),\n      );\n      \n      /// Other test code goes here.\n    });\n  });\n}\n```\n\nAll HTTP GET requests inside the closure of `provideMockedNetworkImages` will receive a mocked image response, and your tests will not crash with 404's anymore.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froughike%2Fimage_test_utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froughike%2Fimage_test_utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froughike%2Fimage_test_utils/lists"}