Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to perform golden test of screen having loading state ? #151

Open
pranavo72bex opened this issue Mar 10, 2022 · 3 comments
Open

How to perform golden test of screen having loading state ? #151

pranavo72bex opened this issue Mar 10, 2022 · 3 comments

Comments

@pranavo72bex
Copy link

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...',)
        ],
      ),
    );
  }
}
@tsimbalar
Copy link
Contributor

@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

@pranavo72bex
Copy link
Author

pranavo72bex commented Mar 12, 2022

Thanks it work nicely. I am facing three problems.

  1. Because of screen utill package ,text of my app get super scale up.
  2. 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 ?
  3. 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🙏

@tsimbalar
Copy link
Contributor

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:

  1. 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 ?

  2. Font-rendering is different on macOS and linux ... this issue has some pointers : Different font rendering between Unix and macOS #79

  3. again, maybe open a separate issue ... but this sounds like it's not 100% related to this library ? does Can't do a widget test aissat/easy_localization#274 look helpful ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants