スキル一覧に戻る
luvi-team

widget-test

by luvi-team

LUVI – Femtech Flutter App (Flutter + Supabase + DSGVO)

0🍴 0📅 2026年1月25日
GitHubで見るManusで実行

SKILL.md


name: widget-test description: Use when you have implemented a new screen or widget that needs widget tests

Widget Test Skill

Overview

Creates widget tests for Flutter screens/components using LUVI's test infrastructure.

When to Use

  • You just implemented a new screen
  • You created a new reusable widget
  • Keywords: "create test", "widget test", "write tests"

When NOT to Use

  • Unit tests for pure Dart logic (use regular unit tests)
  • Integration tests with backend (use integration test suite)
  • The screen/widget already has tests

Workflow

  1. Create test file under test/features/{feature}/
  2. Use buildTestApp from test/support/test_app.dart
  3. Load localization with AppLocalizations.delegate
  4. Check Semantics with tester.ensureSemantics()

Test Setup

Every test file should start with:

import '../../../support/test_config.dart';

void main() {
  TestConfig.ensureInitialized();

  group('ScreenName', () {
    testWidgets('renders correctly', (tester) async {
      // ...
    });
  });
}

What TestConfig.ensureInitialized() handles:

SetupPurpose
TestWidgetsFlutterBindingFlutter test bindings
VideoPlayerMockPrevents "VideoPlayer not initialized" errors
AuthStrings overrideGerman localization for auth strings
InitMode.testDisables network calls and timers

When to call:

  • Always at the start of void main()
  • Before any group() or testWidgets() calls
  • Only once per test file (not per test)

Quick Reference

buildTestApp

await tester.pumpWidget(
  buildTestApp(child: const MyScreen()),
);
await tester.pumpAndSettle();

Semantics Check

final handle = tester.ensureSemantics();
// ... test
handle.dispose();

Common Finders

find.byType(MyWidget)
find.text('Expected Text')
find.bySemanticsLabel('Semantic Label')

Localization in Tests

buildTestApp already configures AppLocalizations.delegate - no extra setup required.

Accessing L10n:

final l10n = AppLocalizations.of(
  tester.element(find.byType(MyScreen)),
)!;
expect(find.text(l10n.someLabel), findsOneWidget);

Run Tests

scripts/flutter_codex.sh test test/features/{feature}/{test_file}.dart

Common Mistakes

MistakeFix
Missing pumpAndSettle()Call pumpAndSettle() after pumpWidget() for animations
Forgot ensureSemantics()Always call ensureSemantics() before accessibility assertions
Wrong import pathRelative path ../../../support/test_app.dart assumes test is 3 dirs deep (e.g., test/features/auth/login_test.dart). Adjust depth for your location.

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です