mocktail

Creates mocks, stubs, and interaction verifications for Dart and Flutter tests using Mocktail.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill mocktail-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mocktail
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/mocktail
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill mocktail-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Dart and Flutter tests often requires isolating code from its dependencies, and incorrect mocking leads to runtime errors, missed verifications, and brittle tests. This Skill provides the correct patterns for using the Mocktail package so tests stub, match, and verify behavior reliably. ## Core Features & Use Cases - Mock and Fake Creation: Define mocks with extends Mock and lightweight fakes with extends Fake, with no code generation required. - Stubbing and Fallback Registration: Stub synchronous and asynchronous methods with thenReturn, thenThrow, and thenAnswer, and register fallback values for custom types used with argument matchers. - Interaction Verification: Verify call counts, capture arguments, and handle named parameters correctly in when and verify calls. - Use Case: When testing a Flutter repository class that depends on an API service, create a MockApiService, register fallback values in setUpAll, stub the fetch method with thenAnswer, and verify it was called exactly once with the expected arguments. ## Quick Start Use the mocktail skill to write a test that mocks my UserRepository, stubs its fetchUser method, and verifies it was called with the correct user ID.

Frequently Asked Questions about mocktail

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

FAQPage Schema
How do I mock a class in Dart with Mocktail?

Create a mock by declaring a class that extends Mock and implements the target interface, such as `class MockMyService extends Mock implements MyService {}`. Mocktail uses noSuchMethod at runtime, so no code generation is required unlike Mockito.

Mocktail vs Mockito: which should I use for Flutter tests?

Mocktail requires no code generation and works at runtime via noSuchMethod, while Mockito relies on generated code. Choose Mocktail when you want simpler setup for stubbing and interaction verification in Dart and Flutter tests.

Why does Mocktail throw an error when using any() with custom types?

Mocktail requires a registered fallback value for non-nullable custom types used with argument matchers like any() or captureAny(). Call registerFallbackValue with an instance of the type inside setUpAll before running your tests.

How do I stub async methods that return Future in Mocktail?

Stub async methods with thenAnswer instead of thenReturn, for example `when(() => mock.fetchData()).thenAnswer((_) async => 'result')`. For Future<void> methods, use `thenAnswer((_) async {})`.

When should I use a Fake instead of a Mock in Dart tests?

Use a Fake when you need a lightweight custom implementation and do not need to verify interactions. Reserve mocks for tests that verify call counts or arguments, and prefer real objects whenever practical.