Skip to content
pubscout

riverpod_test

0.1.9, released 2 years ago by eronsoft.com

A testing library for easily testing Riverpod providers.

WASM-ready
$ flutter pub add riverpod_test
Source repository

What it does

It provides helper functions like testProvider, testNotifier, and testAsyncNotifier to simplify testing Riverpod providers and notifiers. It allows you to specify actions, expected state emissions, and verification steps.

AI-written summary of version 0.1.9, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using Riverpod for state management and want to write unit tests for your providers.
  • You want to test state changes, async values, and notifiers emitted by Riverpod.

Skip it when

  • Your project does not use Riverpod.
  • You prefer writing standard Dart test blocks without specialized testing wrappers.

Strengths

  • Simplifies testing of various Riverpod provider types including Notifier, AsyncNotifier, and StateNotifier.
  • Port of bloc_test which makes it familiar for developers coming from the BLoC library.

Weaknesses

  • Tightly coupled to the Riverpod state management library.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4

Add the package to your dev_dependencies.

testProvider(
  'expect [0]',
  provider: counterProvider,
  expect: () => [0],
);

final counterProvider = Provider<int>((ref) => 0);

Alternatives

Packages that do the same job and could replace riverpod_test.

Works with

Packages commonly used together with riverpod_test: ones it builds on, ones built on it, and its own family.