You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I might be missing something obvious here, but it seems to me that epics that include timers break tests, even if one explicitly tears down the store.
Here's the simplest possible repro:
voidmain() {
group('repro', () {
testWidgets('test', (tester) async {
final store =Store<String>(
(state, dynamic action) => state,
initialState:'Greetings!',
middleware: [
EpicMiddleware(_middleware),
],
);
final widget =StoreProvider<String>(
store: store,
child:MaterialApp(
home:StoreConnector<String, String>(
converter: (s) => s.state,
builder: (context, state) =>Text(state),
// At least one dispatch is required, otherwise the epic is never initialized
onInit: (store) => store.dispatch('whatever'),
),
),
);
await tester.pumpWidget(widget);
await store.teardown();
});
});
}
Stream<dynamic> _middleware(Stream<dynamic> actions, EpicStore<String> store) =>Observable<dynamic>(actions).debounceTime(aSecond).ignoreElements();
Running this gives:
_AssertionError ('package:flutter_test/src/binding.dart': Failed assertion: line 1050 pos 7: '_currentFakeAsync.nonPeriodicTimerCount == 0': A Timer is still pending even after the widget tree was disposed.)
One silly little workaround I could use (just tested and it seems to work) is to define my own Teardown action that I dispatch (only from tests) when I want to bring things to an end. All relevant epics can listen for that action as a means of terminating their pipelines.
Heya @kentcb -- after a long search, the fundamental reason all of these timers are breaking has finally been tracked down and is being discussed here: dart-lang/sdk#40131
Gonna close this out of this repo since there's really nothing I can do to fix this :/
Hi,
I might be missing something obvious here, but it seems to me that epics that include timers break tests, even if one explicitly tears down the store.
Here's the simplest possible repro:
Running this gives:
I considered doing something like this:
But it appears as though the
actions
stream never completes either (even when tearing down the store).Am I doing something wrong here?
The text was updated successfully, but these errors were encountered: