Repository: flutter
Issue: Testing localized widgets can fail when assets are too big due to race condition
Labels: a: tests,c: crash,framework,f: material design,a: internationalization,d: api docs,has reproducible steps,P3,found in release: 3.3,workaround available,found in release: 3.7,team-design,triaged-design

Fix: https://github.com/flutter/flutter/issues/22193#issuecomment-1046333568

---

I've found a [LINK](https://stackoverflow.com/questions/52463714/how-to-test-localized-widgets-in-flutter?answertab=oldest#tab-top) with exact same question but didn't help.

Could you write some examples of testing localized widgets?
Below is what I've tried.

```dart
  testWidgets('Sample Widget', (WidgetTester tester) async {
    // Create the Widget tell the tester to build it
    await tester.pumpWidget(Localizations(
      delegates: [
        const LocalizationDelegate(),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      locale: Locale('en'),
      child: Sample(sample: 'test'),
    ));
    await tester.pumpAndSettle();

    expect(find.text('test'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    // Tap the '+' icon and trigger a frame.
//    await tester.tap(find.byIcon(Icons.add));
//    await tester.pump();
  });
```

Result
```
➜ dooboo git:(master) ✗ flutter test test/widgets/sample.dart
00:07 +0: Sample Widget                                                                                                                            
locale: en
languageCode: en
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: ?:<zero widgets with text "test" (ignoring offstage widgets)>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///Users/hyochan/Documents/SourceCode/FlutterProjects/dooboo/test/widgets/sample.dart:29:5)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:72:23)
#6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:559:19)
<asynchronous suspension>
#9      TestWidgetsFlutterBinding._runTest (package:flutter_test/src/binding.dart:543:14)
#10     AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:887:24)
#16     AutomatedTestWidgetsFlutterBinding.runTest (package:flutter_test/src/binding.dart:884:15)
#17     testWidgets.<anonymous closure> (package:flutter_test/src/widget_tester.dart:71:22)
```
flutter doctor
```
[✓] Flutter (Channel beta, v0.7.3, on Mac OS X 10.14 18A384a, locale en-KR)
[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] iOS toolchain - develop for iOS devices (Xcode 10.0)
    ✗ ios-deploy not installed. To install:
        brew install ios-deploy
[✓] Android Studio (version 3.1)
[!] VS Code (version 1.27.2)
[✓] Connected devices (1 available)

! Doctor found issues in 3 categories.
```