> flutter-testing
Unit, widget, and integration testing with robots, widget keys, and Patrol. Use when writing Flutter unit tests, widget tests, or integration tests with Patrol. (triggers: **/test/**.dart, **/integration_test/**.dart, **/robots/**.dart, lib/core/keys/**.dart, test, patrol, robot, WidgetKeys, patrolTest, blocTest, mocktail)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/flutter-testing?format=md"Flutter Testing Standards
Priority: P0 (CRITICAL)
Core Rules
- Test Pyramid: Unit > Widget > Integration.
- Naming:
should <behavior> when <condition>. - AAA: Arrange, Act, Assert in all tests.
- Shared Mocks:
test/shared/only — no local mocks. - File Placement:
_integration_test.dartONLY inintegration_test/. - Robot-First: ALL UI assertions/interactions via
*Robot— never rawfind.*/expect()in test body.
Test Organization (ref)
- Widget tests →
test/features/<feature>/*_test.dart. - Integration →
integration_test/<feature>/*_integration_test.dart. - Patrol: share robots via import; native
$.native.*in test file, not robot. - Group: core tests +
Edge casesgroup per file. - Cover: empty/null, errors, loading, boundary values, role variants.
Widget Keys (ref)
abstract final classinlib/core/keys/<feature>/. Import barrel only.- Format:
<feature>.<screen>.<element>. Never inlineKey('string').
Robot Pattern (ref)
- All interactions/assertions in
*Robot— never inline in tests. - Accept
WidgetTester; shared by widget + Patrol integration tests. - Symmetric: every
expectXxxVisible()needsexpectXxxNotVisible(). - Widget tests: include
pumpScreen(bloc:, settle:)helper. - Integration tests: methods work without
pumpScreen(real app running). - Integration robots: provide
expectVAppBarVisible(),tapBackButton(),expectContentVisible().
Integration Testing (ref)
- Use
IntegrationAuthHelper.loginOrSkip($)for authenticated flows. - Extract navigation-to-deep-screen into helper functions returning
bool. - Create robot:
final robot = FeatureRobot($.tester)— same class as widget tests. - Only
$.native.*and navigation helpers may remain inline in test body. - No
v_dlsimports in tests when robots handle all assertions.
Widget Testing & Mocking (ref) (mocking)
TestWrapper.init()insetUpAll+tester.pumpLocalizedWidget(...).- Stub
bloc.state+bloc.streaminsetUp. GetIt when bloc created internally. whenListenfor transitions;settle: falsefor loading/stream states.- Shared mocks in
test/shared/. Prohibitany()/anyNamed(). - Stub ALL dependent blocs. Fake classes for external services.
Anti-Patterns
- No inline Key: Use
WidgetKeysconstant. Noany(): Use typed matchers. - No local mocks: Use
test/shared/. No missing bloc stub: Stubstate+stream. - No test-body logic: Move
find.*/expect()to robot. No raw find in integration tests. - No
_integration_test.dartintest/: Rename or merge. - No unused imports: Remove
v_dlswhen robots handle assertions. Check Material import needs. - No happy-path-only: Add
Edge casesgroup. No one-sided assertions: AddexpectNotVisiblepairs. - No unchecked text casing: Verify
.toUpperCase(),.tr()in source.
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)