-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Is your feature request related to a problem? Please describe.
We have a general test bench for our app in a utility function. There, a certain set of default overrides is passed to a ProviderScope.
In riverpod 2.6, we passed any more specific overrides from the outside into the utility function, thereby overriding the default overrides.
This no longer works with 3.0, because having a duplicated override is prevented with a check.
Describe the solution you'd like
Because we didn't see any way to filter overrides before passing them into ProviderScope, we thought the best way is to skip the check in testing. It seems like a dev utility to catch any dev mistakes. But for us it's intended behavior.
Describe alternatives you've considered
Using a Map of provider to override and merging them was considered but is a lot of boilerplate.
Checking overrides for equality, which is also not easily possible from the outside.
Wrapping multiple ProviderScopes also doesn't work.
Additional context
Our testing setup:
class TestBench extends StatelessWidget {
const TestBench({
super.key,
this.locale = const Locale('en'),
this.overrides = const [],
required this.child,
});
final Locale locale;
final List<Override> overrides;
final Widget child;
@override
Widget build(BuildContext context) {
return ProviderScope(
overrides: [
// ... lots of other other global overrides...
buildNumberProvider.overrideWithValue('000'),
configurationProvider.overrideWithValue(
mockConfiguration.copyWith(
supportedLocales: [locale],
),
),
// external overrides, specific to the test
...overrides,
],
child: child,
);
}
}