mohanadarafe / GuideMe

SOEN 390 | Winter 2020 | Mini Capstone
7 stars 5 forks source link

Fix failing CurrentLocation unit test (CurrentLocation.test.js) #105

Closed bkenza closed 4 years ago

bkenza commented 4 years ago

Creating a test for the CurrentLocation component makes the Travis build fail although it passes locally. The error thrown is the following:

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down.
      at Object.get AsyncStorage [as AsyncStorage] (node_modules/react-native/Libraries/react-native/react-native-implementation.js:179:12)
      at Timeout._onTimeout (components/CurrentLocation.js:878:20)
/home/travis/build/mohanadarafe/GuideMe/components/CurrentLocation.js:878
      _reactNative.AsyncStorage.setItem("altitude", altitude);
                                ^
TypeError: _reactNative.AsyncStorage.setItem is not a function
    at Timeout._onTimeout (/home/travis/build/mohanadarafe/GuideMe/components/CurrentLocation.js:33:26)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

To reproduce bug

  1. Create a unit test for the CurrentLocation component (very basic, use the existing tests as a template)
  2. Push your code on GitHub
  3. Watch the build fail and throw the mentioned error