mcpField
T
testing-flutter

testing-flutter

github.com/thebeardedbearsasTesting & quality107203 installsUpdated today
Repository

About testing-flutter

Testing guidance for developers working with Flutter and Dart, including projects using BLoC or Riverpod. It covers BLoC v9 and Riverpod 3.0 testing patterns with examples.

Key features

  1. 01bloc_test patterns for BLoC v9
  2. 02Riverpod 3.0 Mutation testing
  3. 03Guidelines for testing practices

Use cases

  1. 01Test BLoC states and events
  2. 02Verify state updates from Riverpod Mutations
  3. 03Plan a Flutter project testing approach

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/thebeardedbearsas/claude-craft --skill testing-flutter

After installing, type/testing-flutterin Claude Code to confirm it loaded.

Details

From the project README

Testing Flutter 3.44+ - Stratégie Complète

Versions : Flutter 3.44+ | Dart 3.12+ | BLoC v9 | Riverpod 3.0

Patterns de test 2026

BLoC v9 Tests avec bloc_test
// pubspec.yaml
dev_dependencies:
  bloc_test: ^10.0.0
  mocktail: ^1.0.0

// Test avec emit.isDone checks (BLoC v9)
blocTest<UserBloc, UserState>(
  'emits [loading, loaded] when FetchUser is added',
  build: () {
    when(() => mockUseCase.call('123'))
        .thenAnswer((_) async => User(id: '123', name: 'Alice'));
    return UserBloc(getUserUseCase: mockUseCase);
  },
  act: (bloc) => bloc.add(const FetchUser('123')),
  expect: () => [
    const UserState(status: UserStatus.loading),
    const UserState(status: UserStatus.loaded, user: User(id: '123', name: 'Alice')),
  ],
  verify: (bloc) {
    // Vérifier que le bloc respecte isDone (v9)
    verify(() => mockUseCase.call('123')).called(1);
  },
);
Riverpod 3.0 Mutations Tests
// Test Riverpod 3.0 Mutations API
test('Mutation updates state correctly', () async {
  final container = ProviderContainer();
  
  // Initial state
  final notifier = container.read(orderNotifierProvider('123').notifier);
  expect(container.read(orderNotifierProvider('123')).value?.id, '123');
  
  // Mutation
  await notifier.updateOrder(Order(id: '123', name: 'Updated'));
  
  // Verify state après mutation
  expect(
    container.read(orderNotifierProvider('123')).value?.name,
    'Updated',
  );
  
  container.dispose();
});

Source : Riverpod 3.0 Testing


This skill provides guidelines and best practices.

See ../../rules/07-testing-flutter.md for detailed documentation.

Comments

Markdown supported