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
When running detox with metro in mock mode. It should mock the createMMKV call. The check for this is based on a platform checker that checks isJest(). I don't think this is a good way to do this or the way metro has intended.
The way metro works is that you configure it to prefer mock files over regular files when run in mock mode, through the sourceExts in your metro config. So it will completely ignore the regular file and use the .mock file instead.
This means in the current setup that the regular createMMKV() function will not exist. This is not a good practice. What you should do instead is import only from './createMMKV'. and give the mock version of the call in your .mock file the same name. This way the call will always exist and the mock variant is picked based on how metro is started, not based on if you are running with jest (that call didn't work for me). Refactoring this might break some existing logic though. So what I did is I created a patch with PlatformChecker.mock.js which contained isJest() => true; this works because when metro is started in mock mode it will pick the isJest call from the mock file and always return true. Which I think is a better check than actually checking for jest. since the calls are dependant on mock files, not jest. I don't think this breaks the existing logic.
The text was updated successfully, but these errors were encountered:
When running detox with metro in mock mode. It should mock the createMMKV call. The check for this is based on a platform checker that checks isJest(). I don't think this is a good way to do this or the way metro has intended.
The way metro works is that you configure it to prefer mock files over regular files when run in mock mode, through the
sourceExts
in your metro config. So it will completely ignore the regular file and use the .mock file instead.This means in the current setup that the regular createMMKV() function will not exist. This is not a good practice. What you should do instead is import only from './createMMKV'. and give the mock version of the call in your .mock file the same name. This way the call will always exist and the mock variant is picked based on how metro is started, not based on if you are running with jest (that call didn't work for me). Refactoring this might break some existing logic though. So what I did is I created a patch with PlatformChecker.mock.js which contained
isJest() => true;
this works because when metro is started in mock mode it will pick the isJest call from the mock file and always return true. Which I think is a better check than actually checking for jest. since the calls are dependant on mock files, not jest. I don't think this breaks the existing logic.The text was updated successfully, but these errors were encountered: