0
votes

I have some issue with react-native-firebase, I have a Windows environment and I want to do a Test using Jest, So when I run an npm test I got Test suite failed

because I have a react-native-firebase Package and it should be integration in IOS, I just rename the File Android and unlink react-native-firebase to avoid these but it's not working for me! So how I Handle this if I don't have a Mac

Test Code

/**
 * @format
 * @lint-ignore-every XPLATJSCOPYRIGHT1
 */

import "react-native";
import React from "react";
import App from "../App";
import SignIn from "../src/screens/SignIn";

// Note: test renderer must be required after react-native.
import renderer from "react-test-renderer";

// it("renders correctly", () => {
//   renderer.create(<App />);
// });

test("renders correctly", () => {
  const tree = renderer.create(<SignIn />).toJSON();
  expect(tree).toMatchSnapshot();
});

Test Result

 FAIL  __tests__/App.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.

      at new Firebase (node_modules/react-native-firebase/dist/modules/core/firebase.js:28:13)
      at Object.<anonymous> (node_modules/react-native-firebase/dist/modules/core/firebase.js:97:21)
      at Object.<anonymous> (node_modules/react-native-firebase/dist/index.js:1:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        6.137s
Ran all test suites.
npm ERR! Test failed.  See above for more details.
1
cc: @auticcat !DevAS

1 Answers

0
votes

You can use import {Platform} from 'react-native';

import {Platform} from 'react-native';

if(Platform.OS !== 'ios') {
test("renders correctly", () => {
  const tree = renderer.create(<SignIn />).toJSON();
  expect(tree).toMatchSnapshot();
});

}