riverpod-testing

Test Riverpod providers and widgets with ProviderContainer and overrides.

Updated Mar 28, 2026
One-click install
npx skills add https://github.com/masssi164/weave --skill riverpod-testing-masssi164
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: riverpod-testing
Source: https://github.com/masssi164/weave/tree/main/.agent/skills/riverpod-testing
Command: npx skills add https://github.com/masssi164/weave --skill riverpod-testing-masssi164

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Riverpod testing patterns reduce flakiness and increase confidence by isolating state per test, enabling provider overrides, and validating behavior without spinning up a full app.

Core Features & Use Cases

  • Unit tests (no Flutter): Use ProviderContainer.test() to create a container for the test. Read provider values with container.read(provider) and observe changes with container.listen(provider, callback).
  • Widget tests: Wrap the widget under test with ProviderScope and interact via tester.container() to inspect provider state.
  • Mocking providers: Apply overrides to substitute real providers with test doubles, enabling deterministic scenarios.
  • Awaiting async providers: Read provider.future and await completion to validate asynchronous values.
  • Listening / spying: Use container.listen to capture sequences of values over time for assertions.
  • Mocking Notifiers: Prefer replacing dependencies used by Notifiers with mocks rather than rewriting notifier logic.

Quick Start

Create a unit test for Riverpod providers using ProviderContainer and overrides to verify behavior in isolation.

Frequently Asked Questions about riverpod-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Riverpod providers in isolation without building a full Flutter app?

Test Riverpod providers in isolation by using ProviderContainer.test() to create a container, reading provider values with container.read(), and observing changes with container.listen() to verify behavior independently.

What is the best way to mock dependencies when testing Riverpod providers?

Mocking dependencies in Riverpod testing is done using provider overrides. You substitute real providers with test doubles to create deterministic scenarios without rewriting notifier logic.

How do I test async Riverpod providers and validate their final values?

To test async Riverpod providers, read provider.future and await its completion. This allows you to validate asynchronous values deterministically once the provider resolves.

Can I use ProviderScope to inspect provider state during Flutter widget tests?

Yes, you can wrap the widget under test with ProviderScope and interact via tester.container() to inspect provider state during Flutter widget tests.

Why does my Riverpod test flake when checking sequences of values over time?

Riverpod tests flake when state is not isolated. Use container.listen to capture and spy on sequences of values over time, and apply overrides to ensure deterministic behavior for reliable assertions.

Do I need Flutter to run unit tests for Riverpod providers?

No, you do not need Flutter to run unit tests for Riverpod providers. You can use ProviderContainer.test() directly to validate provider logic without spinning up a Flutter environment.