Closed Olshansk closed 7 years ago
@jjh42 Want to ping this back up. Would appreciate any help!
Hi @Olshansk, mocking happens at the global level and tests with mocks cannot run concurrently. Or, well, they can, but the behaviour will be nondeterministic.
From the readme:
Currently, mocking modules cannot be done asynchronously, so make sure that you are not using async: true in any module where you are testing.
@tompave That makes sense. Thanks for the reply!
I'm mocking the same module in two different test files.
If I set
async: true
in both of these test files, I get the following error:The workaround is to set
async: false
in at least one of the two files where the same module is being mocked.Without investigating how
:meck
is implemented, I think I have a good guess as to why this is happening and understand that the root cause of the issue is the interdependence of my unit tests; I really shouldn't be mocking the same module in two different places.Without refactoring my tests, do you have a suggestion for a workaround to have them run asynchronously?