0

I have the default codebase configuration in Flutter and I want to write a sample snapshot test for the MyApp widget, inside that widget is a demo for a counter.

This is my code:

group('GoldenBuilder', () { goldenTest( 'Counter Snapshot ', fileName: 'tests', builder: () => GoldenTestGroup( scenarioConstraints: const BoxConstraints(maxWidth: 600), children: [ GoldenTestScenario( name: 'without color', child: const FancyContainer(), ), GoldenTestScenario( name: 'with black color', child: const FancyContainer(color: Colors.black), ), GoldenTestScenario( name: 'with white color', child: const MyApp(), ), ], ), ); });

Error will replicate when I add this part GoldenTestScenario( name: 'with white color', child: const MyApp(), ),

I also tried using the statefull widget MyHomePage() then wrapped it in a MaterialApp() but still error occurs.

after running flutter test --update-goldens

Hoping someone could help me which part I missed configured.

Error Image Error Image

Tried wrapping in a MaterialApp() and call MyHomePage stateful widget Tried creating new widget and calling this new widget created is working fine.

It should be success after running flutter test --update-goldens and should be added in the red box.

Output

Pusoy
  • 13
  • 3

0 Answers0