Getting started
Writing tests is simple, if you already know how to test a Flutter app you're almost ready.
If you don't know how to test Flutter apps head hover to Flutter docs
Check how I tested the examples that I provided:
SolidOverride
The SolidOverride
widget is a widget that allows you to override the Solid
providers, regardless of their position in the widget tree.
Here is an example:
testWidgets(
'SolidOverride overrides providers regardless of the hierarchy',
(tester) async {
await tester.pumpWidget(
SolidOverride(
providers: [
Provider<Signal<int>>(create: () => Signal(100)),
],
child: MaterialApp(
home: Solid(
providers: [
Provider<Signal<int>>(create: () => Signal(0)),
],
builder: (context) {
final counter = context.observe<Signal<int>>().value;
return Text(counter.toString()); // 100
},
),
),
),
);
expect(find.text('100'), findsOneWidget);
});
As you can see, the Signal
provider returned is the overriden one.
This happens because the SolidOverride
widget is the first place where the provider is searched.