Closed kzjn10 closed 2 years ago
This worked for me. Wanted to share in case it's helpful for someone else.
Future<Widget> makeTestableWidget() async {
var delegate = await LocalizationDelegate.create(
fallbackLocale: 'de',
supportedLocales: ['de', 'en'],
basePath: 'path_to_translations_folder',
);
return LocalizedApp(delegate, App());
}
void main() {
group('use-case', () {
testWidgets('test-case-1', (WidgetTester tester) async {
var app = await makeTestableWidget();
await tester.pumpWidget(app);
await tester.pumpAndSettle();
await expectLater(
find.byType(app.runtimeType), matchesGoldenFile('<path_to_snapshot>'));
});
});
}
Please update the document to handle unit test.