Testing in Flutter

Sep 19 2023 · Dart 2.19.3, Flutter 3.7.6, Android Studio 2021.3.1, Visual Studio Code 1.7.4

Part 5: Generate Goldens

15. Generate Your First Golden

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 14. Reuse Widget Test in Integration Test Next episode: 16. Widget Extension Functions

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

This video will teach us about Goldens and how to generate them. Goldens are the screenshots of the widgets. We can use these goldens to compare the UI changes. So if there are any UI changes, we can compare the goldens and see what has changed. We can generate goldens by writing code.

await expectLater(
  find.byType(LoginScreen),
  matchesGoldenFile('login_screen.png'),
);
flutter test --update-goldens
await expectLater(
  find.byType(LoginScreen),
  matchesGoldenFile('invalid_credentials.png'),
);

await expectLater(
  find.byType(LoginScreen),
  matchesGoldenFile('valid_credentials.png'),
);

await await expectLater(
  find.byType(LoginScreen),
  matchesGoldenFile('show_indicator.png'),
);

await expectLater(
  find.byType(LoginScreen),
  matchesGoldenFile('login_screen.png'),
);

await expectLater(
  find.byType(LoginScreen),
  matchesGoldenFile('all_quotes_init.png'),
);