SkillAgentSearch skills...

mocktail

Use when creating mocks, stubbing methods, verifying interactions, registering fallback values, or choosing between mocks, fakes, and real objects (Mocktail).

Install / Use

npx skills add evanca/flutter-ai-rules --skill mocktail

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

87/100

Supported Platforms

Universal

Tags

Our assessment of mocktail

mocktail scores 87/100 on our quality scale, 1750th of 4,634 Development & Engineering skills we index (top 38%).

Its SKILL.md is 3.2 KB long, well organised into 9 sections with 6 code examples: a solid amount of guidance for an agent.

It has 646 GitHub stars, a meaningful sign that others use it.

Substance
26/30
Structure
20/20
Description
15/15
Adoption
12/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated 19 days ago, so mocktail is actively maintained.
  • It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

mocktail compared with similar skills

All 4 of these similar skills score higher than mocktail; compare them before choosing.

SkillScoreStarsUpdatedFormat
mocktail (this skill)by evanca8764619d agoSKILL.md
ai-job-searchby MadsLorentzen10044.9ktodayCLAUDE.md
claude-howtoby luongnv8910041.7k3d agoCLAUDE.md
algorithmic-artby anthropics100177.9k11d agoSKILL.md
pptxby anthropics100177.9k11d agoSKILL.md

Frequently asked questions

How do I install mocktail?
Run npx skills add evanca/flutter-ai-rules --skill mocktail. The install tabs above show the steps for each supported agent.
Which AI agents does mocktail work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is mocktail safe to use?
It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is mocktail still maintained?
The repository was last updated 19 days ago, so mocktail is actively maintained.

name: mocktail description: "Use when creating mocks, stubbing methods, verifying interactions, registering fallback values, or choosing between mocks, fakes, and real objects (Mocktail)." license: MIT

Mocktail Skill

This skill defines how to correctly use the mocktail package for mocking in Dart and Flutter tests.


1. Mock vs. Fake vs. Real Object

| Use | When | |---|---| | Real object | Prefer over mocks when practical. | | Fake (extends Fake) | Lightweight custom implementation; override only the methods you need. Prefer over mocks when you don't need interaction verification. | | Mock (extends Mock) | Only when you need to verify interactions (call counts, arguments) or stub dynamic responses. |

  • Never add @override methods or implementations to a class extending Mock.
  • Only use mocks if your test has verify assertions; otherwise prefer real or fake objects.

2. Creating Mocks

class MockMyService extends Mock implements MyService {}
class FakeMyEvent extends Fake implements MyEvent {}

No code generation required — unlike Mockito, Mocktail uses noSuchMethod at runtime.


3. Registering Fallback Values

Register fallback values before using custom types with argument matchers. Do this in setUpAll or at the top of your test:

setUpAll(() {
  registerFallbackValue(FakeMyEvent());
});
  • Required for non-nullable custom types used with any(), captureAny(), or captureThat().
  • Register fallback values for any custom type used with argument matchers.

4. Stubbing

final mock = MockMyService();

// Return a value
when(() => mock.fetchData()).thenReturn('result');

// Throw an error
when(() => mock.fetchData()).thenThrow(Exception('error'));

// Dynamic/async response
when(() => mock.fetchData()).thenAnswer((_) async => 'result');

// Future<void>
when(() => mock.doWork()).thenAnswer((_) async {});
  • Always stub async methods (returning Future or Future<void>) with thenAnswer.
  • Stub every method you expect to be called, even if it's not the focus of your test.

5. Named Parameters

Always include all named parameters in both when and verify calls. Use any(named: 'paramName') for those you don't care about:

when(() => mock.fetch(
  id: any(named: 'id'),
  headers: any(named: 'headers'),
)).thenReturn(response);
  • If a method has default values for named parameters, Mocktail still expects them all to be matched.

6. Verification

verify(() => mock.fetchData());             // called at least once
verifyNever(() => mock.fetchData());        // never called
verify(() => mock.fetchData()).called(2);   // called exactly twice

7. Argument Matchers

// Any positional argument
when(() => mock.process(any())).thenReturn(true);

// Capture arguments for later assertions
final captured = verify(() => mock.process(captureAny())).captured;
print(captured.last);
  • Use any() for positional parameters when you don't care about the exact value.
  • Use captureThat() for conditional capturing.
  • When matching string output, be aware of what .toString() returns for the type.

References

Related Skills

View on GitHub
GitHub Stars646
CategoryDevelopment
Updated19d ago
Forks67

Languages

Shell

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

No cautions