Skip to content

fix: test widget with animation and image #136

@vlkonoshenko

Description

@vlkonoshenko

Is there an existing issue for this?

  • I have searched the existing issues.

Version

0.10.0

Description

The error occurs when trying to test a widget with an image and infinite animation

Steps to reproduce

  1. When testing a widget with an image and an endless animation,
  2. If it is a precacheImages function, and it has a command at the end, await tester.pumpAndSettle(), then it waits for the end of the frame rendering, but this doesn't happen because there's an endless animation on the screen.
  3. Perhaps we should extend the precacheImages function with a flag to turn off await tester.pumpAndSettle()?

Expected behavior

The test was completed successfully.

Screenshots

Снимок экрана 2024-11-15 в 11 20 08

Additional context and comments

Example

goldenTest(
    'Animation with image',
    fileName: 'example',
    pumpBeforeTest: precacheImages,
    pumpWidget: (tester, widget) async {
      await tester.pumpWidget(widget);
      await tester.pump(Durations.medium4);
    },
    builder: () {
      return GoldenTestGroup(
        scenarioConstraints:
            const BoxConstraints(maxWidth: 1200, minWidth: 600),
        children: [
          GoldenTestScenario(
            name: 'Animation',
            child: const Column(
              children: [
                CircularProgressIndicator(
                  color: Colors.red,
                ),
                SizedBox.square(
                  dimension: 120,
                  child: Image(image: AssetImage(UiKitImages.cluster)),
                ),
              ],
            ),
          ),
        ],
      );
    },
  );

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions