mocktail

Mock and verify Dart/Flutter tests without code generation using Mocktail.

611|60|Updated Apr 22, 2025
One-click install
npx skills add https://github.com/evanca/flutter-ai-rules --skill mocktail
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mocktail
Source: https://github.com/evanca/flutter-ai-rules/tree/main/skills/mocktail
Command: npx skills add https://github.com/evanca/flutter-ai-rules --skill mocktail

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Mocking Flutter/Dart tests often requires code generation or heavy boilerplate. Mocktail provides a no-codegen approach and guides when to use mocks, fakes, or real objects to keep tests fast and readable.

Core Features & Use Cases

  • Mocking without code generation: Use Mocktail's noSuchMethod-based mocks to verify interactions and stub responses.
  • Fallback values: Register fallback values for non-nullable custom types used with argument matchers.
  • Stubbing & verification: Stub methods with when/thenReturn/thenAnswer and verify interactions using verify/verifyNever/called(n).
  • Argument matchers: Use any, captureAny, and other matchers to flexibly assert calls.

Quick Start

Create mocks by extending Mock and implementing your service, then stub methods with when and thenReturn and verify interactions.

Frequently Asked Questions about mocktail

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

FAQPage Schema
How do I mock Dart and Flutter tests without code generation?

Mock Dart and Flutter tests without code generation by extending the Mock class and implementing your service. Mocktail uses a noSuchMethod approach to stub methods and verify interactions, keeping tests fast and readable.

How do I stub method responses and verify calls in Dart unit testing?

Stub method responses in Dart unit testing using when and thenReturn or thenAnswer. Verify interactions using verify, verifyNever, and called(n), applying argument matchers like any and captureAny for flexible assertions.

Why do I need to register fallback values for argument matchers in Mocktail?

Register fallback values in Mocktail when using argument matchers with non-nullable custom types. This requirement ensures the testing framework has valid default instances to satisfy Dart's null safety constraints during method stubbing and verification.

When should I use mocks, fakes, or real objects in Flutter widget testing?

Use mocks, fakes, or real objects in Flutter widget testing based on your needs: mocks verify interactions via noSuchMethod, fakes provide lightweight implementations, and real objects execute actual logic to ensure accurate behavior.

Does Mocktail work with both unit and widget testing in Dart?

Yes, Mocktail works with both unit and widget testing in Dart and Flutter. It covers mocking, stubbing, and interaction verification across both testing scopes without requiring code generation or heavy boilerplate.