riverpod-testing

Test Riverpod providers and widgets in Dart with ProviderContainer and ProviderScope.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the process of testing Riverpod providers and widgets, enabling robust and isolated unit and widget tests.

Core Features & Use Cases

  • Provider Testing: Write unit tests for Riverpod providers using ProviderContainer.test().
  • Widget Testing: Test widgets that depend on Riverpod providers by wrapping them in ProviderScope.
  • Mocking: Easily mock providers using overrides for isolated testing scenarios.
  • Async Provider Awaiting: Test asynchronous provider values using .future.
  • Listening/Spying: Monitor provider state changes during tests.

Quick Start

Use the riverpod-testing skill to write a unit test for a Riverpod provider.

Frequently Asked Questions about riverpod-testing

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

FAQPage Schema
How do I write a unit test for a Riverpod provider?

Mock Riverpod providers in tests by using the `overrides` parameter within `ProviderContainer.test()` or `ProviderScope`. This replaces real dependencies with mock implementations, ensuring isolated testing scenarios for your widgets and state logic.

How do I test widgets that depend on Riverpod providers?

Test widgets depending on Riverpod by wrapping them in a `ProviderScope` during widget tests. This ensures the widget tree has access to the necessary provider container, allowing you to mock dependencies and verify UI rendering correctly.

Can I test asynchronous Riverpod provider values?

Yes, you can test asynchronous Riverpod provider values by using `.future` to await their resolution. This ensures your unit tests properly handle AsyncValue states and verify the correctness of asynchronous state management logic.

What is the best way to monitor Riverpod provider state changes during a test?

Monitor Riverpod provider state changes during tests by listening to the provider within a `ProviderContainer`. This allows you to spy on state emissions and verify that your Dart application's state management updates occur as expected.

Do I need to override providers for isolated Riverpod widget testing?

Yes, for isolated Riverpod widget testing, you should use `overrides` within the `ProviderScope`. This allows you to substitute real dependencies with mock implementations, ensuring the widget test remains focused on the UI logic.