TF-4141 Adding tearDownAll for GetX cleanup and documentation for proper cleanup, widget wrapping expectations

This commit is contained in:
dab246
2026-01-02 08:57:53 +07:00
committed by Dat H. Pham
parent 4340b0aff2
commit 42a838f263
2 changed files with 27 additions and 0 deletions
@@ -161,4 +161,9 @@ void main() {
);
});
});
tearDownAll(() {
Get.delete<ResponsiveUtils>();
Get.delete<ImagePaths>();
});
}
+22
View File
@@ -21,6 +21,16 @@ class WidgetFixtures {
);
}
/// Sets up responsive testing with the specified [logicalSize] and optional [platform].
///
/// Note: This method modifies global state via [debugDefaultTargetPlatformOverride].
/// Always call [resetResponsive] in your test's tearDown to clean up:
///
/// ```dart
/// tearDown(() {
/// WidgetFixtures.resetResponsive(tester);
/// });
/// ```
static Future<void> setupResponsive(
WidgetTester tester, {
required Size logicalSize,
@@ -42,6 +52,18 @@ class WidgetFixtures {
tester.view.reset();
}
/// Pumps a widget with responsive setup for the specified [logicalSize] and optional [platform].
///
/// Note: This method does not wrap the widget with [makeTestableWidget].
/// If your widget requires localization or GetX context, wrap it first:
///
/// ```dart
/// await WidgetFixtures.pumpResponsiveWidget(
/// tester,
/// WidgetFixtures.makeTestableWidget(child: YourWidget()),
/// logicalSize: Size(800, 600),
/// );
/// ```
static Future<void> pumpResponsiveWidget(
WidgetTester tester,
Widget widget, {