You attempted to use a firebase module that's not installed on your Android project by calling firebase.app() - Jest testing

Viewed 903

I'm trying to test my app using jest but encountered an error "You attempted to use a firebase module that's not installed on your Android project by calling firebase.app()". Below is my code

import firebase from '@react-native-firebase/app';

test('renders correctly', () => {
  Platform.OS = 'android';
  firebase.initializeApp({//credentials hidden
  });
  const _firestore = firebase.firestore();
  const personStore = new PersonStore(_firestore);
  const app = renderer
    .create(
      <Provider {...personStore}>
        <PersonInfo />
      </Provider>,
    )
    .getInstance();
});

What am I missing? I've tried this solution https://rnfirebase.io/install-android but to no avail And @react-native-firebase/app is working if I'm not in test mode

2 Answers

Try the getting started steps: Getting Started

The solution you tried is a secondary step. Also firebase is segmented in modules, so you should install the required modules separated. if you are going to use the firestore you have to install the module. Firestore Module

for me the problem was with mismatch in the package name of the app throughout the project (I started out with a MyApp project and then changed the name but not in all the necessary places).

I then followed these steps to rename everything and it started working

Related