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

Basic Scaffold test throws exceptions #183

Open
BinaryShrub opened this issue Dec 18, 2023 · 1 comment
Open

Basic Scaffold test throws exceptions #183

BinaryShrub opened this issue Dec 18, 2023 · 1 comment

Comments

@BinaryShrub
Copy link

BinaryShrub commented Dec 18, 2023

Scaffold() is not working in the most basic test and is throwing exceptions. A test with just MaterialApp() will work, but add in a Scaffold() and it blows up.

with:

import 'package:flutter/material.dart';
import 'package:golden_toolkit/golden_toolkit.dart';

void main() {
  testGoldens('MaterialApp with Scaffold blows up', (tester) async {
    final builder = GoldenBuilder.grid(columns: 2, widthToHeightRatio: 1)
      ..addScenario(
          'MaterialApp',
          const MaterialApp(
            home: Scaffold(),
          ));
    await tester.pumpWidgetBuilder(builder.build());
    await screenMatchesGolden(tester, 'material_app');
  });
}

run:

flutter test

result:

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performResize():
'package:flutter/src/widgets/overlay.dart': Failed assertion: line 1117 pos 12:
'constraints.biggest.isFinite': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

The relevant error-causing widget was:
  MaterialApp MaterialApp:file:///mnt/c/workspace/sandbox/test/test.dart:9
[stacktrace.txt](https://github.com/eBay/flutter_glove_box/files/13709302/stacktrace.txt)
:17                                                                                                                                                                                                                                                                                                                       

stacktrace.txt

@BinaryShrub
Copy link
Author

For others who run into this, using the baked in matchesGoldenFile works just fine:

testWidgets('Golden Test', (WidgetTester tester) async {
    await tester.pumpWidget(const MaterialApp(
      home: Scaffold(
        body: Text('test'),
      ),
    ));

    await expectLater(
        find.byType(MaterialApp), matchesGoldenFile('myGoldenFile.png'));
  });

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

1 participant