{"id":19197169,"url":"https://github.com/verygoodopensource/mockingjay","last_synced_at":"2025-04-04T12:06:42.134Z","repository":{"id":41146963,"uuid":"360310714","full_name":"VeryGoodOpenSource/mockingjay","owner":"VeryGoodOpenSource","description":"A package that makes it easy to mock, test, and verify navigation in Flutter. Created by Very Good Ventures 🦄","archived":false,"fork":false,"pushed_at":"2025-03-19T14:44:11.000Z","size":235,"stargazers_count":114,"open_issues_count":3,"forks_count":9,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-28T11:08:49.678Z","etag":null,"topics":["dart","flutter","flutter-navigation","flutter-package","mock","mocking"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/mockingjay","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VeryGoodOpenSource.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-21T21:26:53.000Z","updated_at":"2025-03-19T14:40:27.000Z","dependencies_parsed_at":"2023-11-09T15:28:00.800Z","dependency_job_id":"717c2ea4-b280-4631-9b2d-e60a9e7f0ad5","html_url":"https://github.com/VeryGoodOpenSource/mockingjay","commit_stats":{"total_commits":53,"total_committers":11,"mean_commits":4.818181818181818,"dds":0.7735849056603774,"last_synced_commit":"bb623ccea0f92697d0aaf91e9a64c987f9771cf5"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeryGoodOpenSource%2Fmockingjay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeryGoodOpenSource%2Fmockingjay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeryGoodOpenSource%2Fmockingjay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeryGoodOpenSource%2Fmockingjay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VeryGoodOpenSource","download_url":"https://codeload.github.com/VeryGoodOpenSource/mockingjay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174415,"owners_count":20896078,"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":["dart","flutter","flutter-navigation","flutter-package","mock","mocking"],"created_at":"2024-11-09T12:15:43.777Z","updated_at":"2025-04-04T12:06:42.118Z","avatar_url":"https://github.com/VeryGoodOpenSource.png","language":"Dart","readme":"# 🕊 mockingjay\n\n[![Very Good Ventures][logo_white]][very_good_ventures_link_dark]\n[![Very Good Ventures][logo_black]][very_good_ventures_link_light]\n\nDeveloped with 💙 by [Very Good Ventures][very_good_ventures_link] 🦄\n\n[![ci][ci_badge]][ci_link]\n[![coverage][coverage_badge]][ci_link]\n[![pub package][pub_badge]][pub_link]\n[![License: MIT][license_badge]][license_link]\n[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_badge_link]\n\n---\n\nA package that makes it easy to mock, test and verify navigation calls in Flutter. It works in tandem with [`mocktail`][mocktail], allowing you to mock a navigator the same way you would any other object, making it easier to test navigation behavior independently from the UI it's supposed to render.\n\n## Usage\n\nTo use the package in your tests, install it via `dart pub add`:\n\n```shell\ndart pub add dev:mockingjay\n```\n\nThen, in your tests, create a `MockNavigator` class like so:\n\n```dart\nimport 'package:mockingjay/mockingjay.dart';\n\nfinal navigator = MockNavigator();\n```\n\nNow you can create a new `MockNavigator` and pass it to a `MockNavigatorProvider`.\n\nAny widget looking up the nearest `Navigator.of(context)` from that point will now receive the `MockNavigator`, allowing you to mock (using `when`) and `verify` any navigation calls. Use the included matchers to more easily match specific route names and types.\n\n**Note**: make sure the `MockNavigatorProvider` is constructed **below** the `MaterialApp`. Otherwise, any `Navigator.of(context)` call will return a real `NavigatorState` instead of the mock.\n\n## Example\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:flutter_test/flutter_test.dart';\nimport 'package:mockingjay/mockingjay.dart';\n\nclass MyHomePage extends StatelessWidget {\n  const MyHomePage({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      body: TextButton(\n        onPressed: () =\u003e Navigator.of(context).push(MySettingsPage.route()),\n        child: const Text('Navigate'),\n      ),\n    );\n  }\n}\n\nclass MySettingsPage extends StatelessWidget {\n  const MySettingsPage({super.key});\n\n  static Route\u003cvoid\u003e route() {\n    return MaterialPageRoute(\n      builder: (_) =\u003e const MySettingsPage(),\n      settings: const RouteSettings(name: '/settings'),\n    );\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return const Scaffold();\n  }\n}\n\nvoid main() {\n  testWidgets('pushes SettingsPage when TextButton is tapped', (tester) async {\n    final navigator = MockNavigator();\n    when(navigator.canPop).thenReturn(true);\n    when(() =\u003e navigator.push\u003cvoid\u003e(any())).thenAnswer((_) async {});\n\n    await tester.pumpWidget(\n      MaterialApp(\n        home: MockNavigatorProvider(\n          navigator: navigator,\n          child: const MyHomePage(),\n        ),\n      ),\n    );\n\n    await tester.tap(find.byType(TextButton));\n\n    verify(\n      () =\u003e navigator.push\u003cvoid\u003e(\n        any(\n          that: isRoute\u003cvoid\u003e(\n            whereName: equals('/settings'),\n          ),\n        ),\n      ),\n    ).called(1);\n  });\n}\n\n```\n\n[ci_badge]: https://github.com/VeryGoodOpenSource/mockingjay/workflows/mockingjay/badge.svg\n[ci_link]: https://github.com/VeryGoodOpenSource/mockingjay/actions\n[coverage_badge]: https://raw.githubusercontent.com/VeryGoodOpenSource/mockingjay/main/coverage_badge.svg\n[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[license_link]: https://opensource.org/licenses/MIT\n[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only\n[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only\n[mocktail]: https://pub.dev/packages/mocktail\n[pub_badge]: https://img.shields.io/pub/v/mockingjay.svg\n[pub_link]: https://pub.dartlang.org/packages/mockingjay\n[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg\n[very_good_analysis_badge_link]: https://pub.dev/packages/very_good_analysis\n[very_good_ventures_link]: https://verygood.ventures\n[very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only\n[very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverygoodopensource%2Fmockingjay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverygoodopensource%2Fmockingjay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverygoodopensource%2Fmockingjay/lists"}