wiser-technology-solutions/rx_bloc/golden-test
Claude Code and agent skill by wiser-technology-solutions/rx_bloc
- community
Checking that the SKILL.md file is still in the repository.
Create Golden tests for an existing feature - Deterministic, convention-compliant golden test generation for feature pages
Install
npx vskill@latest install wiser-technology-solutions/rx_bloc/golden-testSKILL.md
Create Golden Tests for a Feature
This skill guides the AI agent in creating golden tests for Flutter feature pages, adhering strictly to the established architecture and patterns.
Reference implementation:test/feature_profile/— this is the canonical example
Inputs Required
To successfully execute this skill, the following inputs MUST be provided:
- Feature name: A feature name or its project path (e.g.,
feature_profileorlib/feature_profile)
Core Principle
Convention conformance > Visual coverage > Quantity
Every golden test must follow the exact patterns from the reference implementation. The agent must understand the infrastructure before generating any test.
Scope
Golden tests cover whole pages/screens only.
- One golden test file per page
- Placed in
test/feature_<name>/view/ - Individual UI components do NOT require separate golden tests
Infrastructure Overview
Package
The project uses the Alchemist package (package:alchemist/alchemist.dart).
Global Config: test/flutter_test_config.dart
- File path resolution: Strips
_light/_darksuffix from the scenario name and routes the.pngintogoldens/light_theme/orgoldens/dark_theme/ - Comparator:
ProcreditFileComparatorwith 0% tolerance - MaterialApp wrapper: Wraps with
ProI18n,I18n,GlobalMaterialLocalizationsandDesignSystem.fromBrightness(Brightness.light)theme - Default locale:
Locale('bg')
You never specify a path to goldens/ manually. The scenario name + theme enum determine the output path automatically.
Theme Enum: test/helpers/enums/app_themes.dart
Default Devices: test/helpers/golden_helper.dart
Every golden renders across 7 devices:
| Device | Size | Pixel Ratio | Safe Area | |
|---|---|---|---|---|
| iPhone SE (2nd gen) | 375×667 | 2.0 | top: 20 | |
| Google Pixel 4a | 412×732 | 1.0 | none | |
| iPhone 13 mini | 375×812 | 3.0 | top: 44, bottom: 34 | |
| Google Pixel 5 | 393×851 | 2.75 | top: 24, bottom: 48 | |
| Samsung Galaxy S20 | 412×915 | 3.0 | top: 24, bottom: 48 | |
| Samsung Galaxy Tab S6 | 1280×800 | 2.0 | top: 24, bottom: 48 | |
| Apple iPad Pro 12.9 | 1024×1366 | 2.0 | top: 24, bottom: 34 |
Directory Structure (MANDATORY)
- NEVER manually create or move
.pngfiles - Dark theme images go in
goldens/dark_theme/(when enabled)
File Naming Conventions (MANDATORY)
| Artifact | Pattern | Example | |
|---|---|---|---|
| Golden test file | <page_snake_case>_golden_test.dart | profile_golden_test.dart | |
| Factory file | <page_snake_case>_factory.dart | profile_factory.dart | |
| Mock file | <bloc_snake_case>_mock.dart | profile_mock.dart | |
| Generated mock | <bloc_snake_case>_mock.mocks.dart | profile_mock.mocks.dart | |
| Golden image | <scenario_name>.png (auto-resolved) | profile_success.png |
Scenario Naming (MANDATORY)
The scenario name passed to Scenario(name: '...') becomes the golden filename.
Format:
Rules:
- Always snake_case
- Start with the page prefix (e.g.,
profile_,branch_network_page_) - End with the state/variant (e.g.,
_success,_loading,_error) - Must be unique across the test file
- The
_light/_darksuffix is appended automatically — never add it yourself
Examples:
| Scenario Name | Meaning | |
|---|---|---|
profile_success | default success state | |
profile_success_toggled | success with biometrics/notifications enabled | |
profile_loading | loading state | |
profile_error | error state |
Step-by-Step Execution Plan
1. Analysis Phase (Before Generating)
Before generating golden tests for any feature, the agent MUST:
- [ ] Read
lib/feature_<name>/views/to identify the page and its UI states - [ ] Read
lib/feature_<name>/di/to identify all provider dependencies - [ ] Read
lib/feature_<name>/blocs/to identify all BLoC state streams - [ ] Read
test/feature_<name>/to inventory existing test coverage - [ ] Check
test/mocks/stubs.dartfor available test data - [ ] Check
test/mocks/andtest/base/for existing shared mock factories - [ ] Verify all required mocks exist or plan their creation
- [ ] Enumerate all scenarios following the naming convention
2. Create BLoC Mock Factories
In test/feature_<name>/mock/<bloc>_mock.dart:
Critical Mock Rules:
@GenerateMocksgoes in the mock file, never in the test or factory file- Every state exposed by the BLoC's States class must be wired (prevents
MissingStubError) - Null/absent parameters should emit
const Stream.empty() - Run
dart run build_runner buildafter creating/modifying mock files
Stream wiring conventions:
| Stream type | Pattern | |
|---|---|---|
| Simple fire-once (errors, loading) | Stream.value(x) or const Stream.empty() | |
| States needing replay (dialogs, toggles) | .publishReplay(maxSize: 1)..connect() | |
| States needing sharing | .share() or .shareReplay(maxSize: 1) |
3. Create Widget Factory
In test/feature_<name>/factory/<page>_factory.dart:
Critical Factory Rules:
- Use expression body (
=> Scaffold(...)) — no block body, no local variables - Accept optional/named parameters for each UI state dimension
- Parameters map 1:1 to BLoC state streams
- Wrap the page in
Scaffoldbody - Provide all required BLoC providers via
MultiProvider+RxBlocProvider<T>.value
Factory MUST NEVER:
- Import
package:mockito/mockito.dart - Import
../../mocks/stubs.dart - Contain
when()/thenAnswer()/thenReturn()calls - Instantiate real services
- Contain any stubbing logic
4. Create Golden Test File
In test/feature_<name>/view/<page>_golden_test.dart:
Key API:
runGoldenTests(List<ScenarioBuilder>)— iterates over allThemes.values, callsgoldenTestfor each scenario+themegenerateDeviceBuilder(widget:, scenario:)— renders the widget across all 7 default devices- Optional parameters:
customPumpBeforeTest,customDeviceHeight,locale
setUp() usage:
If the page requires global setup (e.g., isTest = true, VisibilityDetectorController), add a setUp() block before runGoldenTests:
Test Data Rules
ALL test data MUST come from test/mocks/stubs.dart
This includes:
- Model instances (e.g.,
Stubs.profile,Stubs.error) - Strings, numbers, IDs
- Lists and collections
Also use:
ProfileModel.withDefaults()for default profile dataResult.success(data),Result.loading(),Result.error(Stubs.error)for state wrappersLoadingWithTag(loading: true)for loading states
Forbidden:
- Inline model construction in test or factory files
- Hardcoded literals in test or factory files
- If new data is needed, add it to
stubs.dartfirst
State Coverage Matrix
For every page, the agent MUST enumerate and cover:
| Dimension | Values | |
|---|---|---|
| Data state | success, loading, error, empty (if applicable) | |
| Interaction state | expanded/collapsed, toggled on/off, selected/unselected | |
| Edge cases | missing optional data, overlay/modal visible | |
| Theme | light (+ dark when enabled in Themes enum) | |
| Locale | bg (default); add others only if layout visually differs |
Create one generateDeviceBuilder call per unique combination that produces a visually distinct render.
Do NOT create scenarios for combinations that render identically.
Forbidden Actions
- NEVER manually create, rename, or move
.pnggolden files - NEVER use
@GenerateMocksinside a test file or factory file - NEVER put
when()/thenAnswer()/thenReturn()calls inside a factory file - NEVER import
package:mockito/mockito.dartin a factory file - NEVER import
stubs.dartin a factory file - NEVER instantiate real services inside a factory file
- NEVER use block body (
{ return ... }) in a factory — use expression body (=>) - NEVER define test data inline in test files
- NEVER add
_lightor_darksuffix to scenario names - NEVER skip wiring a state stream in the mock factory
Reference: Key Import Paths
In golden test files:
In factory files (NO mockito, NO stubs):
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/.agents/skills/golden_test/SKILL.md
Popularity
- Repository stars
- 67
- Repository forks
- 20
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wiser-technology-solutions/rx_bloc/golden-test)