Mocking expo-file-system's bundleDirectory

Hi all,

I am trying to test a hook that relies on the bundleDirectory property from expo-file-system.

I am using jest-expo@39.0.0 which as I understand it should be mocking out these native modules - and I see that it does for the other methods in this package.

However, bundleDirectory is not defined and due to that I cannot spy on it and provide a mocked value.

If I modify jest-expo/src/preset/setup.js to return bundleDirectory with a mocked property for the expo-file-system mock, I get the mocked property but I am still not able to spy on it due to it not being configurable.

Is there something else I can modify to make this work? Is there a reason expo-file-system has a mock declared both in setup.js and in expoModules.js?

1 Like

May be related to typescript - How do you mock FileSystem.cacheDirectory in jest? - Stack Overflow

Interesting, I see bundleDirectory in the types but it always comes back as null