Skip to content

test(goldens): a custom pumpBeforeTest silently drops the precacheImages default #903

Description

@marassteiner

The project wrapper test/helper/golden_test_with_assets.dart:51 exists specifically to default pumpBeforeTest to alchemist.precacheImages:

alchemist.PumpAction pumpBeforeTest = alchemist.precacheImages,

Any golden test that passes its own pumpBeforeTest callback therefore replaces the precaching, not extends it. That is invisible at the call site — the callback looks like an addition, and nothing warns that the wrapper's entire reason for existing has just been switched off for that test.

Current impact: none

Checked for the call sites in test/goldens/screens/support/support_create_ticket_golden_test.dart: the support ticket page and its widgets contain no Image.asset / FadeInImage / SvgPicture, so there is nothing to precache and the baselines are unaffected. This is a latent hazard, not a present defect.

Why it is worth recording

The failure mode is silent and delayed: the first asset image added to a screen whose golden overrides pumpBeforeTest renders blank or flaky in the baseline, and the cause (a callback in a different file, written months earlier) is far from the symptom.

Suggested fix

Compose instead of replace — have the wrapper run alchemist.precacheImages and then the caller's callback, e.g.

pumpBeforeTest: (tester) async {
  await alchemist.precacheImages(tester);
  await callerPumpBeforeTest(tester);
},

so an override cannot drop the default, or document the override semantics in the wrapper's dartdoc.

Context

Surfaced while reviewing #897, which adds such a callback. Pre-existing pattern (several golden tests already override pumpBeforeTest), not a merge blocker for that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions