Jest test runner failing to import Expo modules

#1

I’m writing some component tests for a React Native app, and I’m using Expo’s BarCodeScanner for one of my components. In my Jest test I have a line that says: import { BarCodeScanner } from ‘expo’;. This line alone (without anything that uses it further down in my test code) causes the following error:

“The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.”

This error also seems to appear when importing any Expo module into Jest. Anybody have any idea on how I can import the BarCodeScanner to my test file?

closed #2

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.