AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified BSD-3-Clause Self-run

Riverpod Testing

skill-serverpod-skills-registry-riverpod-testing · by serverpod

Test Riverpod providers and widgets; ProviderContainer.test, unit tests, widget tests with ProviderScope, tester.container(), mocking with overrides, container.listen for auto-dispose, awaiting .future. Use when writing unit or widget tests for Riverpod code, mocking providers, or testing with overrides. Use this skill when the user asks about testing Riverpod, mocking providers, or ProviderConta…

No reviews yet
0 installs
15 views
0.0% view→install

Install

$ agentstack add skill-serverpod-skills-registry-riverpod-testing

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-serverpod-skills-registry-riverpod-testing)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
5mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Riverpod Testing? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Riverpod — Testing

Instructions

Riverpod is designed for testability: isolate state per test, mock via overrides, and keep the test environment close to production.

Unit tests (no Flutter)

Use ProviderContainer.test() to create a container for the test. Do not share containers between tests.

void main() {
  test('Some description', () {
    final container = ProviderContainer.test();
    expect(container.read(provider), equals('some value'));
  });
}
  • container.read(provider) — Read current value.
  • container.listen(provider, (prev, next) {}) — Listen and get a subscription; use subscription.read() to read. Prefer listen when the provider is auto-dispose so it is not disposed mid-test.
final subscription = container.listen(provider, (_, _) {});
expect(subscription.read(), 'Some value');

Widget tests

Wrap the widget under test in ProviderScope:

testWidgets('Some description', (tester) async {
  await tester.pumpWidget(
    const ProviderScope(child: YourWidgetYouWantToTest()),
  );
});

To interact with providers in the test, get the container with tester.container():

final container = tester.container();
expect(container.read(provider), 'some value');

Mocking providers

Use overrides on ProviderContainer or ProviderScope. All providers can be overridden without extra setup.

final container = ProviderContainer.test(
  overrides: [
    exampleProvider.overrideWith((ref) => 'Hello from tests'),
  ],
);

// Or in widget tests:
await tester.pumpWidget(
  ProviderScope(
    overrides: [exampleProvider.overrideWith((ref) => 'Hello from tests')],
    child: const YourWidgetYouWantToTest(),
  ),
);

See riverpod-overrides for family overrides and other override methods.

Awaiting async providers

Read provider.future to get a Future that completes with the provider value; use with expectLater:

await expectLater(
  container.read(provider.future),
  completion('some value'),
);

Listening / spying

Use container.listen(provider, callback) and assert on the callback arguments or collect values in a list for assertions. Works with mockito/mocktail verify patterns.

Mocking Notifiers

Prefer mocking a dependency (e.g. repository) the Notifier uses rather than mocking the Notifier. If you must mock a Notifier, subclass it (do not implement), so the mock extends the original base class. With code generation, the mock usually needs to live in the same file as the Notifier to access the generated base class.

See riverpod-overrides and the official docs for more examples.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.