mocktailx 0.0.4
mocktailx: ^0.0.4 copied to clipboard
A set of utility functions over mocktail library created to increase productivity over daily mocking/testing.
mocktailx #
A set of utility functions for mocktail apis.
Usage #
First import mocktailx to your pubspec:
mocktailx: ^0.0.4
Note that this library is a container for mocktail 0.3.0
, so you don't need to import mocktail.
And don't forget to fix your imports:
import 'package:mocktailx/mocktailx.dart';
Features #
thenAnswerWithVoid
// Instead of doing:
when(repo.futureVoidFunction).thenAnswer((invocation) async {});
// You can just:
when(repo.futureVoidFunction).thenAnswerWithVoid();
thenAnswerWith(T)
// Instead of doing:
when(repo.futureIntFunction).thenAnswer((invocation) async => 10);
// You can just:
when(repo.futureIntFunction).thenAnswerWith(10);
thenEmit(List)
// Instead of doing:
when(repo.streamValue).thenAnswer((invocation) => Stream.fromIterable([1,2,3,4,5]));
// You can just:
when(repo.streamValue).thenEmit([1,2,3,4,5]);
thenReturnWithVoid
// Instead of doing:
when(repo.voidFunction).thenReturn(null);
// You can just:
when(repo.voidFunction).thenReturnWithVoid();