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
Hi, I am facing a problem with widget tests. If the widget I am testing has a UseQueryResult, the test fails because of a pending timer. Here is the stack trace:-
Pending timers:
Timer (duration: 0:03:00.000000, periodic: false), created:
#0 new FakeTimer._ (package:fake_async/fake_async.dart:308:62)
#1 FakeAsync._createTimer (package:fake_async/fake_async.dart:252:27)
...
...
...
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test:
A Timer is still pending even after the widget tree was disposed.
'package:flutter_test/src/binding.dart':
Failed assertion: line 1542 pos 12: '!timersPending'
When the exception was thrown, this was the stack:
#2 AutomatedTestWidgetsFlutterBinding._verifyInvariants (package:flutter_test/src/binding.dart:1542:12)
#3 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1049:7)
<asynchronous suspension>
<asynchronous suspension>
(elided 3 frames from class _AssertionError and package:stack_trace)
It looks like it is because of the cacheDuration (the one that if I change its value, the second line in the stack trace I provided change). I tried to set the cacheDuration to 0 but I get the same error. Is there a way to either dispose that timer (and other timers if there are any) or not creating it in tests from the beginning?
The text was updated successfully, but these errors were encountered:
Hi, I am facing a problem with widget tests. If the widget I am testing has a
UseQueryResult
, the test fails because of a pending timer. Here is the stack trace:-It looks like it is because of the
cacheDuration
(the one that if I change its value, the second line in the stack trace I provided change). I tried to set thecacheDuration
to 0 but I get the same error. Is there a way to either dispose that timer (and other timers if there are any) or not creating it in tests from the beginning?The text was updated successfully, but these errors were encountered: