flutter_fbi_test 0.1.6 copy "flutter_fbi_test: ^0.1.6" to clipboard
flutter_fbi_test: ^0.1.6 copied to clipboard

Testing helpers for the Flutter FBI library (featureTest helper).

flutter_fbi_test #

Testing helpers for the flutter_fbi package. Provides a small, focused featureTest helper to simplify unit-testing Feature classes from flutter_fbi.

Features

  • Lightweight test helper for Feature classes
  • Separate assertions for states and side-effects
  • Minimal surface area — depends on flutter_fbi and flutter_test

Installation

Add to your dev_dependencies in pubspec.yaml:

dev_dependencies:
  flutter_fbi_test: ^0.1.5
  flutter_test:
    sdk: flutter

API

@isTest
void featureTest<E extends UiEvent, S extends FeatureState, F extends SideEffect>(
  String description, {
  FutureOr<void> Function()? setUp,
  required Feature<E, S, F> Function() build,
  S Function()? seed,
  FutureOr<void> Function(Feature<E, S, F> feature)? act,
  Iterable<Object?> Function()? expect,
  Iterable<Object?> Function()? expectSideEffects,
  int skip = 1, // skip initial state by default
  Duration? wait,
  FutureOr<void> Function(Feature<E, S, F> feature)? verify,
})

Basic usage

import 'package:flutter_fbi_test/flutter_fbi_test.dart';

featureTest<CounterEvent, CounterState, CounterSideEffect>(
  'increments once',
  build: () => CounterFeature(),
  act: (feature) => feature.add(IncrementEvent()),
  expect: () => [CounterState(count: 1)],
);

With side-effects and wait

featureTest<AuthEvent, AuthState, AuthSideEffect>(
  'login success shows toast',
  build: () => AuthFeature(),
  act: (f) => f.add(LoginRequested('u', 'p')),
  expect: () => [isA<AuthLoading>(), isA<AuthSuccess>()],
  expectSideEffects: () => [isA<ShowToastEffect>()],
  wait: const Duration(milliseconds: 50),
);

Guidance

  • Keep this package in dev_dependencies — it is intended for tests only
  • Keep skip at default 1 to skip the initial seeded state
  • Use wait if your feature emits asynchronously after act

License

Apache License 2.0 — see LICENSE for details

1
likes
140
points
172
downloads

Publisher

unverified uploader

Weekly Downloads

Testing helpers for the Flutter FBI library (featureTest helper).

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter_fbi, flutter_test, meta

More

Packages that depend on flutter_fbi_test