Open voidsp opened 2 years ago
I wrap await stream.first
in tester.runAsync
and it works.
group('subject test', () {
testWidgets('wait first', (tester) async {
final subject = BehaviorSubject<String>();
subject.add('my-value');
final Stream<String> stream = subject.stream;
await tester.runAsync(() async {
expect(await stream.first, 'my-value');
});
await subject.close();
});
});
Thank you @hoc081098, is this a regression in rxdart? I'm not sure why wrapping it in tester.runAsync
is now required.
I'm still running into this - unfortunately wrapping our entire widget test in runAsync causes it to fail for other reasons so its not a reasonable workaround for us.
I've found that this for some reason fixes the tests await stream.doOnData((_) {}).first
but seems like an ugly hack.
Hello! After I have upgraded from rxdart 0.27.1 to 0.27.5, my tests have started failing. I found the test starts failing from rxdart 0.27.2:
This test only fails when using
flutter_test
instead oftest
(however, in the actual test case I need to useflutter_test
as there are some widgets being tested), so the interesting thing is this test will work:The first code snippet test (with
flutter_test
) now just hangs, but previously it ran correctly in rxdart 0.27.1. The second code snippet (withtest
) works on all version of rxdart.