invertase / react-native-firebase-starter

DEPRECATED: For RNFB v5 only.
https://rnfirebase.io/docs
Other
1.17k stars 335 forks source link

[help-wanted] Add tests example #21

Open mfogel opened 6 years ago

mfogel commented 6 years ago

After following the getting started instructions, running npm test results in an error:

 FAIL  ./App.test.js
  ● Test suite failed to run

    RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects `Podfile` and have run `pod install`.

     See http://invertase.link/ios for the ios setup guide.

       9 | } from 'react-native'
      10 |
    > 11 | import firebase from 'react-native-firebase'
      12 |
      13 | export default class App extends React.Component {
      14 |   constructor () {
      Error: RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects `Podfile` and have run `pod install`.

This has already been reported in the react-native-firebase repo and it appears this is expected behavior - according to that thread RNFirebase needs to be mocked out for the tests to work.

Assuming that's all correct, I would propose adding a basic mock for RNFirebase to this starter project and enabling it by default.

Salakar commented 6 years ago

@mfogel when mocking was recommended it was pre Detox days, now we'd 100% recommend using Detox to run your tests end to end (greybox testing) - you won't need to mock anything and it's as close to real world testing your app as you're gonna get.

Detox: wix/detox


If you're looking for an opinionated all-in-one starter kit with Detox baked in + RNFirebase then I'd recommend this one: ueno-llc/react-native-starter - it's great 👌

The goal of this starter kit was to be as raw and close to create-react-native-app's output as possible without you having to fiddle with RNFirebase integrations - no opinions, no bloat etc.

Admittedly Detox integrated with this kit + CI would be awesome and should probably be part of this as standard - we'd love someone to PR this or start the ball rolling on this - will mark this issue as help wanted if anyone wants to pick this up.


For reference: our tests suite also uses Detox + Bridge over here: invertase/react-native-firebase/master/bridge

anushbmx commented 5 years ago

Here is a mock file for jest to mock react-native-firebase https://gist.github.com/chrchm/b437be0a8da3343d83e40e820bcfda11