Skip to content

Commit

Permalink
refactor: app initialization logic in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dtscalac committed Sep 19, 2024
1 parent 624f438 commit f6bdeef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
5 changes: 2 additions & 3 deletions catalyst_voices/integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:catalyst_voices/app/view/app.dart';
import 'package:catalyst_voices/configs/bootstrap.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:catalyst_voices/app/app.dart';
import 'package:integration_test/integration_test.dart';

void main() {
Expand All @@ -10,9 +10,8 @@ void main() {
testWidgets('tap on the floating action button, verify counter',
(tester) async {
final args = await bootstrapTest();
// Load app widget.
await tester.pumpWidget(App(routerConfig: args.routerConfig));
await Future<void>.delayed(Duration(seconds: 5));
await tester.pumpAndSettle(Duration(seconds: 15));
});
});
}
18 changes: 1 addition & 17 deletions catalyst_voices/lib/configs/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,6 @@ Future<void> bootstrap([
}

Future<BootstrapArgs> bootstrapTest() async {
// There's no need to call WidgetsFlutterBinding.ensureInitialized()
// since this is already done internally by SentryFlutter.init()
// More info here: https://github.com/getsentry/sentry-dart/issues/2063
if (!kReleaseMode) {
WidgetsFlutterBinding.ensureInitialized();
}

FlutterError.onError = (details) {
log(
details.exceptionAsString(),
stackTrace: details.stack,
);
};

GoRouter.optionURLReflectsImperativeAPIs = true;
setPathUrlStrategy();

Expand All @@ -90,9 +76,7 @@ Future<BootstrapArgs> bootstrapTest() async {

await Dependencies.instance.init();

final args = BootstrapArgs(routerConfig: router);

return args;
return BootstrapArgs(routerConfig: router);
}

Future<void> _runApp(Widget app) async {
Expand Down

0 comments on commit f6bdeef

Please sign in to comment.