Closed juanmanjarres closed 5 months ago
Are you sure there are no errors with String in Text() ? Text('${counterStore.count}',),
Yes sorry I didn't copy the example correctly. The problem is still there though
There is nothing wrong with this behavior, I would appreciate it if you could provide a reproducible source code repository.
// card_test.dart
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_test/flutter_test.dart';
import 'counter_store.dart';
void main() {
testWidgets('Card with incrementing count', (WidgetTester tester) async {
final counterStore = CounterStore();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Observer(
builder: (_) => Text(
'${counterStore.count}',
),
),
),
);
counterStore.increment();
await tester.pump();
expect(find.text('1'), findsOneWidget);
});
}
flutter test test
00:02 +1: All tests passed!
Hi, I was trying to implement some widget tests using
testWidgets
but I can't seem to be able to get those to work with observables. I'm wondering if there's any issues with that specifically? TheCard
never updates, it always stays with the same value of 0 even though I callincrement()
. I've also tried to use thetester.runAsync()
and waiting for an update but it doesn't work.Here's some small code that shows the issue: