riverpod_testing_library 0.2.0 riverpod_testing_library: ^0.2.0 copied to clipboard
A testing library which makes it easy to test providers. Built to be used with the riverpod package.
import 'package:riverpod_testing_library/riverpod_testing_library.dart';
import 'package:test/test.dart';
import '../test/test_utils/notifier/counter.dart';
void main() {
group('provider_test', () {
group('Counter NotifierProvider', () {
providerTest<int>(
'emits the initial state when fireImmediately is true',
provider: counterProvider,
fireImmediately: true,
expect: () => [0],
);
providerTest<int>(
'emits [] when nothing is done',
provider: counterProvider,
expect: () => [],
);
providerTest<int>(
'emits [1] when Counter.increment() is called',
provider: counterProvider,
act: (container) =>
container.read(counterProvider.notifier).increment(),
expect: () => [1],
);
});
});
}