Matt R
Matt R

Reputation: 10503

Flutter golden tests capture empty screenshots

I'm trying to get Flutter golden tests to work, for example:

testWidgets('Golden test', (WidgetTester tester) async {
    final widget = Directionality(
      textDirection: TextDirection.ltr,
      child:  Text('foo'),
    );
    await tester.pumpWidget(widget);
    await expectLater(find.byType(Text), matchesGoldenFile('golden.png'));
  });

However, the captured screenshot is just a white rectangle on a transparent background: https://i.sstatic.net/xm1E5.png

I've also tried putting it inside a Material, and a few other things, but none have actually rendered the widget in a way you might expect on a device.

I'm working on OS X, Flutter 1.9.1+hotfix.4.

Upvotes: 2

Views: 813

Answers (1)

0p3r4t0r
0p3r4t0r

Reputation: 683

By default Flutter golden tests do not load fonts, but you may be able to get them like this . . .

await loadAppFonts();

Checkout golden_toolkit: loading fonts for details.

Upvotes: 3

Related Questions