mockingjay
Flutter에서 네비게이션을 모킹하고 테스트하며 검증하는 것을 쉽게 만들어주는 패키지입니다. Very Good Ventures 🦄 에 의해 제작됨
- 스타
- 116
- 포크
- 11
- 최근 푸시(UTC)
- 2026. 4. 14.
- 프로젝트 상태
- 보관됨
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
🕊 mockingjay
Developed with 💙 by Very Good Ventures 🦄
⚠️ This package is deprecated and no longer actively maintained.
The Flutter ecosystem has shifted toward Navigator 2.0 and declarative routing solutions such as
go_router. Mockingjay, which targets Navigator 1.0 APIs, no longer aligns with the direction of the ecosystem.The repository remains public and available to fork. For full migration guidance, see DEPRECATION.md.
A package that makes it easy to mock, test and verify navigation calls in Flutter. It works in tandem with 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.
Usage
To use the package in your tests, install it via dart pub add:
dart pub add dev:mockingjay
Then, in your tests, create a MockNavigator class like so:
import 'package:mockingjay/mockingjay.dart';
final navigator = MockNavigator();
Now you can create a new MockNavigator and pass it to a MockNavigatorProvider.
Any 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.
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.
Example
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockingjay/mockingjay.dart';
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: TextButton(
onPressed: () => Navigator.of(context).push(MySettingsPage.route()),
child: const Text('Navigate'),
),
);
}
}
class MySettingsPage extends StatelessWidget {
const MySettingsPage({super.key});
static Route<void> route() {
return MaterialPageRoute(
builder: (_) => const MySettingsPage(),
settings: const RouteSettings(name: '/settings'),
);
}
@override
Widget build(BuildContext context) {
return const Scaffold();
}
}
void main() {
testWidgets('pushes SettingsPage when TextButton is tapped', (tester) async {
final navigator = MockNavigator();
when(navigator.canPop).thenReturn(true);
when(() => navigator.push<void>(any())).thenAnswer((_) async {});
await tester.pumpWidget(
MaterialApp(
home: MockNavigatorProvider(
navigator: navigator,
child: const MyHomePage(),
),
),
);
await tester.tap(find.byType(TextButton));
verify(
() => navigator.push<void>(
any(
that: isRoute<void>(
whereName: equals('/settings'),
),
),
),
).called(1);
});
}
분류
사용 중인 의존성
의존성 목록 6 개
- flutter
{"sdk":"flutter"} - flutter_test
{"sdk":"flutter"} - matcher
^0.12.17 - mocktail
^1.0.4 - test
^1.26.3 - very_good_analysis개발 의존성
^10.0.0
프로젝트에 맞는 저장소를 선택하려면?
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
- 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
- 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
- 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.
출처 및 관리
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗

