Skip to content
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

Cannot mock Socket #317

Open
jeiea opened this issue Jan 26, 2023 · 0 comments
Open

Cannot mock Socket #317

jeiea opened this issue Jan 26, 2023 · 0 comments

Comments

@jeiea
Copy link

jeiea commented Jan 26, 2023

#313 changes DartySocket extension to access this.io. This makes me unable to mock Socket as described in mockito FAQ.

I'm using DartySocket.onError, and because mockito doesn't support deep stubbing when accessing io it throws the following.

FakeUsedError (FakeUsedError: 'io'
No stub was found which matches the argument of this method call:
io

A fake object was created for this call, in the hope that it won't be ever accessed.
Here is the stack trace where 'io' was called:

#0      new SmartFake (package:mockito/src/mock.dart:235:41)
#1      new _FakeManager_3 (file:///Users/jeiea/Documents/app/test/utils/test_utils.mocks.dart:105:7)
#2      MockSocket.io (file:///Users/jeiea/Documents/app/test/utils/test_utils.mocks.dart:1140:36)
#3      DartySocket.onError (package:socket_io_client/src/darty.dart:31:10)

I thought some workarounds and maybe I can bypass this by making new interface, but can it be redesigned to support mocking easily if it is possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants