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

Widget testing with FlareActor #123

Open
parlux opened this issue Jul 10, 2019 · 4 comments
Open

Widget testing with FlareActor #123

parlux opened this issue Jul 10, 2019 · 4 comments

Comments

@parlux
Copy link

parlux commented Jul 10, 2019

flutter: 1.5.4-hotfix.2
flare_flutter: 1.5.2

Hi, I'm attempting to run basic widget tests on pages that include a FlareActor, which result in the following error:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
A Timer is still pending even after the widget tree was disposed.
'package:flutter_test/src/binding.dart': Failed assertion: line 1014 pos 7:
'_currentFakeAsync.nonPeriodicTimerCount == 0'

Here is the flutter test I'm running:

import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Widget makeTestableWidget() {
  return MaterialApp(
    home: Scaffold(
      body: Stack(
        children: <Widget>[
          FlareActor(
            "assets/images/tick.flr",
            alignment: Alignment.center,
            fit: BoxFit.contain,
            animation: "success",
          ),
          Text('Success'),
        ],
      ),
    ),
  );
}

void main() {
  group('Flare widget', () {
    testWidgets('renders correctly', (WidgetTester tester) async {
      await tester.pumpWidget(makeTestableWidget());

      expect(find.text('Success'), findsOneWidget);
    });
  });
}

Is there a suggested way to allow these tests to complete? As a workaround I've been navigating away from the page allowing the FlareActor to be disposed and the test to complete, but just wondering if there is a better way to test widgets containing FlareActors.

I believe this may be the same issue as mentioned in a comment in #69

Thanks

@rnewquist
Copy link

I am able to build the widget for testing, but it doesn't ever call initialize for the controller. So I have basic unit tests to see if there is a widget, but I can't test anything with the animations because the art board never gets initialized.

@luigi-rosso
Copy link
Contributor

Take a look at this response in a similar issue: #160 (comment)

@rnewquist
Copy link

@luigi-rosso
That worked perfectly! Thanks so much!

@rnewquist
Copy link

@luigi-rosso how would you go about generating more flares? So i am able to initialize the flare and compare that to a golden. But I can't seem to get the animation to run again to change the tested animation.

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

3 participants