dart-mocktail

Create and manage Mocktail mocks for Dart and Flutter unit tests.

5|Updated Oct 14, 2025
One-click install
npx skills add https://github.com/reloveution/dart-flutter-rules --skill dart-mocktail
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dart-mocktail
Source: https://github.com/reloveution/dart-flutter-rules/tree/main/skills/dart-mocktail
Command: npx skills add https://github.com/reloveution/dart-flutter-rules --skill dart-mocktail

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of creating and managing mock objects in Dart and Flutter projects, reducing boilerplate code and preventing common testing errors like MissingStubError.

Core Features & Use Cases

  • Mock Creation: Easily generate mock classes for interfaces or abstract classes.
  • Fallback Values: Register default values for custom types to avoid errors with matchers.
  • Stubbing & Verification: Define expected behavior for mock methods and verify interactions.
  • Use Case: When testing a service that depends on a repository, use Mocktail to create a mock repository, stub its methods to return predictable data, and verify that the service calls the repository correctly.

Quick Start

Use the dart-mocktail skill to set up fallback values for MyDomainType and stub the fetchData method on MockIRepository to return a predefined list.

Frequently Asked Questions about dart-mocktail

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

FAQPage Schema
How do I fix MissingStubError when unit testing in Dart?

To fix MissingStubError during Dart unit testing, you must explicitly stub mock methods or register fallback values for custom types before executing test assertions. This ensures all mocked dependencies return predictable data instead of throwing unhandled exceptions.

How do I create mocks for Dart and Flutter repository classes?

Creating mocks for Dart and Flutter repository classes involves generating mock instances from abstract interfaces and stubbing their methods. You define expected return values for asynchronous data fetching methods to isolate service logic during unit tests.

What's the best way to verify method calls with parameter matchers in Flutter tests?

The best way to verify method calls with parameter matchers in Flutter tests is using verification methods after execution. You assert that specific mocked repository methods were called with expected arguments, ensuring your service interacts correctly with dependencies.

Why do I need to register fallback values for custom types in Flutter mocking?

You need to register fallback values for custom types in Flutter mocking because parameter matchers require valid default instances. Without registering these defaults, matchers fail to evaluate wildcard arguments during verification, causing runtime errors in your unit tests.

Does Mocktail work for stubbing asynchronous methods in Dart unit tests?

Yes, Mocktail works for stubbing asynchronous methods in Dart unit tests. It allows you to define expected Future or Stream return values for mocked repository methods, ensuring predictable asynchronous data flows during service verification.