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

Create golden tests? #34

Open
HugoHeneault opened this issue Jan 17, 2022 · 1 comment
Open

Create golden tests? #34

HugoHeneault opened this issue Jan 17, 2022 · 1 comment

Comments

@HugoHeneault
Copy link

Hi there!

Monarch looks awesome. I haven't seen anything about creating images of stories, then testing they don't change later.
I'm using https://pub.dev/packages/golden_toolkit which is great to avoid unwanted design changes/regressions.

It would be awesome to create goldens from monarch then test it: great design, then great tests!

Thanks for your cool work here!

@fertrig
Copy link
Collaborator

fertrig commented Jan 18, 2022

Love the feedback!

Visual testing is definitely on our roadmap. We can't wait to start working on it. We think Monarch can drastically improve the golden test experience.

For now, if you are using golden_toolkit, then you can call your stories from your golden tests. Something like this should work:

// my_stories.dart
Widget primaryButton() => ...;
Widget secondaryButton() => ...;
// my_golden_tests.dart
testGoldens('my buttons', (tester) async {
  await tester.pumpWidgetBuilder(
    Center(
        child: (GoldenBuilder.column()
              ..addScenario('primary button',
                  primaryButton())
              ..addScenario('secondary button',
                  secondaryButton())
            .build()),
    surfaceSize: ...,
  );
  await screenMatchesGolden(...);
});

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