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

Lesson 22: Using golden files to verify pixel-perfect widgets #22

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

samuelematias
Copy link
Owner

Description

PR with Lesson 22.

matchesGoldenFile

For the first time, when you run a test (flutter test) with some GoldenFile tests (matchesGoldenFile), you will get an error.

Screen Shot 2020-12-02 at 17 48 57

Because the GoldenFile(s) still doesn't exist, so to fix this error, you need to run the test with this command
flutter test --update-goldens, and your test will pass.

Screen Shot 2020-12-02 at 17 49 50

Now, if you check your project, you will see a new folder inside your test folder, with the name goldens.

Screen Shot 2020-12-02 at 17 51 51

And with some screenshots like this:

calculator_app

Now, if you change something in your code that changes the pixel of the widget, something like changing the AppBar title from Calculator to Calculat:

Screen Shot 2020-12-02 at 17 51 11

Your golden test will fail because of the pixel of the AppBar title change! So, no more pixel-perfect.

Screen Shot 2020-12-02 at 17 52 32

Now, if you check your project, you will see a new folder inside your test folder, with the name failures.

Screen Shot 2020-12-02 at 17 52 22

And with some screenshots indicating where the pixel change, like this:

calculator_app_maskedDiff

Types of changes

  • Fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change which adds Improvements)

@samuelematias samuelematias merged commit e5904e6 into main Dec 2, 2020
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

Successfully merging this pull request may close these issues.

None yet

1 participant