-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflutter_test_config.dart
More file actions
26 lines (24 loc) · 1.19 KB
/
Copy pathflutter_test_config.dart
File metadata and controls
26 lines (24 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import 'dart:async';
import 'package:google_fonts/google_fonts.dart';
/// Runs once before every test under `test/`, discovered automatically by
/// `flutter test`.
///
/// Turning off runtime fetching forces `google_fonts` to resolve the app's
/// typefaces from the bundled assets in `assets/fonts/` instead of downloading
/// them from fonts.gstatic.com. That matters for two reasons:
///
/// * **Determinism.** Goldens render the real Playfair/Nunito faces on every
/// machine, online or not, instead of depending on whether the runner
/// happened to reach Google's CDN.
/// * **It fails loudly.** If `buildAppTextTheme` gains a weight that has no
/// matching file in `assets/fonts/`, `google_fonts` throws and the test
/// fails, rather than silently papering over it with a network fetch that
/// only works on a connected machine.
///
/// If a test starts failing with "allowRuntimeFetching is false but font
/// X was not found", the fix is to add that variant to `assets/fonts/` — not to
/// re-enable fetching. See docs/code/fonts.md.
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
GoogleFonts.config.allowRuntimeFetching = false;
await testMain();
}