Fakes to write unit tests for Firebase Remote Config. Instantiate a FakeRemoteConfig
, then pass it around your project to replace RemoteConfig.instance
. This fake acts like RemoteConfig
except it will load mocked data instead.
import 'package:fake_firebase_remote_config/fake_firebase_remote_config.dart';
void main() async {
final config = FakeRemoteConfig();
await config.setDefaults({
// ...
});
config.loadMockData({
// ...
});
await config.fetchAndActivate();
}
This config
object needs to replace the real RemoteConfig.instance
during testing. You can do this for example with Riverpod or by doing something like this:
await tester.pumpWidget(
MaterialApp(
title: 'RemoteConfig Example',
home: MyApp(overrideRemoteConfig: config),
),
);
config.app
will throwconfig.pluginConstants
will throwconfig.getValue(String key)
will throw if the key is missingconfig.settings
serve no purpose. Data is loaded manually.firebase_remote_config | fake_firebase_remote_config |
---|---|
>=0.9.0-dev.0 <4.0.0 | 1.0.x |
>=4.0.0 <5.0.0 | 2.0.x |
>=4.0.0 <5.0.0 | 2.1.x |
Last updated for firebase_remote_config: 4.2.5
.
Please file feature requests and bugs at the issue tracker.