agentsclimarketplace

Flutter golden testing

Skill anoopsg/agent_rules/src/exclusive/skills/flutter-golden-testing

Behavioral blueprints for agents.

Install
npx -y skills add anoopsg/agent_rules --skill flutter-golden-testing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Step-by-step workflow for creating, configuring, and updating Flutter golden tests using the Alchemist package.

SKILL.md

2.3 KB, as published. Nobody here has run it

Flutter Golden Testing Skill

This skill outlines the step-by-step process for implementing and updating golden tests for Flutter widgets.

Step 1: Validation & Setup

  1. Check Dependencies: Ensure alchemist is present in the dev_dependencies of pubspec.yaml. If it is missing, install it:
    flutter pub add --dev alchemist
    
  2. Directory Structure: Create a goldens/ directory adjacent to your target test file to store the generated .png reference files.

Step 2: Test Scaffolding

Create the test file named [widget_name]_test.dart (or [widget_name]_golden_test.dart).

  1. Imports: Import the necessary packages (package:flutter_test/flutter_test.dart and package:alchemist/alchemist.dart).
  2. Setup Fonts/Assets: Call loadAppFonts() (if applicable) before running the tests to prevent text from rendering as the Ahem font.

Step 3: Implementation

Implement the test using alchemist APIs instead of the standard testWidgets.

  1. Use goldenTest: Define your test using the goldenTest function.
  2. Mock Externalities:
    • Disable or replace infinite animations (e.g., CircularProgressIndicator).
    • Mock network image requests (e.g., using mocktail_image_network or network_image_mock).
  3. Matrix Testing: Use GoldenTestGroup and GoldenTestScenario to lay out all possible widget states (e.g., loading, success, error) and variations (light/dark mode, text scaling) within a single test execution.

Step 4: Generation and Verification

  1. Generate Goldens: Run the following command to generate or update the reference images:
    flutter test --update-goldens
    
  2. Verify Output: Check that the .png files were correctly generated in the goldens/ directory.
  3. Gitignore Failures: Ensure **/failures/ is in the project's .gitignore so test failure artifacts are not accidentally committed.

Step 5: Updating Existing Goldens

If you are modifying an existing widget that already has golden tests, run the update command (flutter test --update-goldens) to regenerate the images. Never modify the .png files manually.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.