-
-
Notifications
You must be signed in to change notification settings - Fork 153
reset changed to async? #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, yes that has, changes, sorry if this caused trouble for you. For the second part I would need to see your test file. |
Thanks for the quick response. I see what happened for the import 'package:get_it/get_it.dart';
import 'package:test/test.dart';
class ToRegister {}
void main() {
final sl = GetIt.instance;
ToRegister registered;
setUpAll(() {
sl.reset();
sl.registerSingleton<ToRegister>(ToRegister());
});
setUp(() {
registered = sl<ToRegister>();
});
test('Registered is found', () {
expect(registered, isNotNull);
});
} And here's the working version: import 'package:get_it/get_it.dart';
import 'package:test/test.dart';
class ToRegister {}
void main() {
final sl = GetIt.instance;
ToRegister registered;
setUpAll(() async {
await sl.reset();
sl.registerSingleton<ToRegister>(ToRegister());
});
setUp(() {
registered = sl<ToRegister>();
});
test('Registered is found', () {
expect(registered, isNotNull);
});
} |
Ah, good to hear. then I can close this issue. |
I did not, I just had a look at get_it_mixin, it look's interesting, thanks for the pointer, and for your work. |
If you really want to go a bit further also check out flutter_command and functional_listener:-) |
Thanks for the package, it's been a pleasure to work with. This is just a minor documentation issue for users upgrading from previous versions. The change to make reset async (I think that's a change?) broke a number of unit tests because instances were already registered since I wasn't doing an
await
for the method to complete before trying to register again. A note in the README could perhaps help reduce the confusion.Another small point that I ran across is that I was setting up test dependencies in the
setupAll
method of my unit test. The dependencies were not then found by get_it in thesetup
method. This used to work and does not work anymore, I'm not sure why.The text was updated successfully, but these errors were encountered: