← Back to list

widget-test
by luvi-team
LUVI – Femtech Flutter App (Flutter + Supabase + DSGVO)
⭐ 0🍴 0📅 Jan 25, 2026
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
- Create test file under
test/features/{feature}/ - Use buildTestApp from
test/support/test_app.dart - Load localization with
AppLocalizations.delegate - 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:
| Setup | Purpose |
|---|---|
TestWidgetsFlutterBinding | Flutter test bindings |
VideoPlayerMock | Prevents "VideoPlayer not initialized" errors |
AuthStrings override | German localization for auth strings |
InitMode.test | Disables network calls and timers |
When to call:
- Always at the start of
void main() - Before any
group()ortestWidgets()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
| Mistake | Fix |
|---|---|
Missing pumpAndSettle() | Call pumpAndSettle() after pumpWidget() for animations |
Forgot ensureSemantics() | Always call ensureSemantics() before accessibility assertions |
| Wrong import path | Relative path ../../../support/test_app.dart assumes test is 3 dirs deep (e.g., test/features/auth/login_test.dart). Adjust depth for your location. |
Score
Total Score
50/100
Based on repository quality metrics
✓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
Reviews
💬
Reviews coming soon