[📚] Documentation Issue – JEST SETUP

Documentation Feedback

https://rnfirebase.io/ does not provide any setup or mock functions for jest at all, furthermore, the internal code of the project made it difficult to write mock functions for jest

In one specific instance where I still have no solution for:

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

const authStatus = await messaging().requestPermission();

we have to use messaging() because internally it is written this way:

  export type FirebaseModuleWithStatics<M, S = {}> = {
    (): M;

This substandard code makes it unnecessarily complex and causes us to unable to mock the ()

jest.mock('@react-native-firebase/messaging', () => ({
  default: jest.fn(),
  (): jest.fn(), // parsing error: unexpected token
}));

Why wouldn’t you follow the conventional coding practice with something like getInstance()?


1 possible answer(s) on “[📚] Documentation Issue – JEST SETUP

[📚] Documentation Issue – JEST SETUP

Documentation Feedback

https://rnfirebase.io/ does not provide any setup or mock functions for jest at all, furthermore, the internal code of the project made it difficult to write mock functions for jest

In one specific instance where I still have no solution for:

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

const authStatus = await messaging().requestPermission();

we have to use messaging() because internally it is written this way:

  export type FirebaseModuleWithStatics<M, S = {}> = {
    (): M;

This substandard code makes it unnecessarily complex and causes us to unable to mock the ()

jest.mock('@react-native-firebase/messaging', () => ({
  default: jest.fn(),
  (): jest.fn(), // parsing error: unexpected token
}));

Why wouldn’t you follow the conventional coding practice with something like getInstance()?


1 possible answer(s) on “[📚] Documentation Issue – JEST SETUP