flutter_glove_box
flutter_glove_box copied to clipboard
How to perform golden test of screen having loading state ?
class RootScreen extends StatelessWidget {
const RootScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: Padding(
padding: const EdgeInsets.only(
bottom: 200,
),
child: Text(
'Test',
),
)),
const Center(
child: CircularProgressIndicator(),
),
Text('Loading...',)
],
),
);
}
}
@pranavo72bex
If you hace a loading indicator, then pumpAndSettle()
will timeout (because there will be an animation forever).
What you can do is that in your calls to screenMatchesGolden()
, you can pass in a customPump
that looks like
customPump: (tester) => tester.pump(Duration(milliseconds: 100)
this will mean that the screen show will happen after 100 ms ... rather than waiting for the screen to stop animating (i.e. default behavior when no customPump
is provided is to use pumpAndSettle
) .
I hope this helps
Thanks it work nicely. I am facing three problems.
- Because of screen utill package ,text of my app get super scale up.
- I have two machines one is Mac and another one is linux but the test file build on Mac fail on linux and vice versa . Fonts of snapshots Mac looks more bold than linux ?
- How to load translation in test BTW I use easy translation package There is no proper documentation about these problem in golden toolkit packages Thanks🙏
Hi @pranavo72bex ,
maybe open separate issues, so that it's easier for people who have the same questions in the future ;)
Also, if you can't find your answers in the documentation, consider searching in the GitHub issues :)
About:
-
not sure I understand. Can you maybe open a separate issue with more information, more details about what you tried, some example of code etc ?
-
Font-rendering is different on macOS and linux ... this issue has some pointers : https://github.com/eBay/flutter_glove_box/issues/79
-
again, maybe open a separate issue ... but this sounds like it's not 100% related to this library ? does https://github.com/aissat/easy_localization/issues/274 look helpful ?