testfairy / react-native-testfairy

React Native component for TestFairy SDK
https://www.testfairy.com
Apache License 2.0
33 stars 12 forks source link

Unable to initialize testfairy #14

Closed slxe6 closed 5 years ago

slxe6 commented 6 years ago

I followed all the steps on testfairy website for integrating with react-native. However when i tried to perform import TestFairy from 'react-native-testfairy'; , it throws me an error saying TestFairy is not defined.

Can you give me pointers what might be causing this?

vijaysharm commented 6 years ago

Hi,

I've just pushed a new version of this library (version 2.6.0) that now supports react-native link. Perhaps you should give this a try and see if it resolves your problem.

ArtyEmsee commented 6 years ago

@vijaysharm

I'm having this same issue and I am running v. 2.6.0. This is the error it's giving me. I ran react-native link and got this feedback:

➜  app-mobile-iphone git:(integratesTFSDK) ✗ react-native link react-native-testfairy

Scanning 1152 folders for symlinks in /Users/robertmcelligott/Documents/advisorconnect/app-

mobile-iphone/node_modules (22ms)

rnpm-install info Android module react-native-testfairy is already linked

rnpm-install info iOS module react-native-testfairy is already linked

rnpm-install info Linking assets to ios project

rnpm-install info Linking assets to android project

rnpm-install info Assets have been successfully linked to your project

screen shot 2018-02-09 at 3 55 30 pm

The code it's failing on is very standard:


import { AppRegistry } from 'react-native';
import App from './App/appEntry';

import TestFairy from 'react-native-testfairy';

TestFairy.begin("keystring");

TestFairy.log("Your log message here");

AppRegistry.registerComponent('AppName', () => App);

Any help would be much appreciated. Thank you,

vijaysharm commented 6 years ago

Hi @ArtyEmsee Thank you for letting us know. I just tried to create a new app and linked TestFairy without problems. Are you able to provide me with a sample that's failing for you, as I cannot seem to reproduce this problem on my end.

vijaysharm commented 6 years ago

This might be silly, but have you tried to replace the import line with this line:

const TestFairy = require('react-native-testfairy');
ArtyEmsee commented 6 years ago

I tried that, no luck. Can you tell me the process you used to create an app and and what version of test fairy you used? I'm going to try to replicate it on my end and isolate test fairy from the app I'm trying to test it on.

vijaysharm commented 6 years ago

Hello, sorry for not getting back to you right away.

So the steps to create an app was pretty straight forward. I used the following commands

> react-native init TestFairy
> cd TestFairy
> npm install --save react-native-testfairy
> react-native link

And i followed the steps in our documentation to initialize the sdk.

You can download a copy of a project i created that works with TestFairy, have a look at this link

In case this information helps, here are the versions i used

> react-native --version 
react-native-cli: 2.0.1
react-native: 0.53.2
dmitryn commented 6 years ago

Was having an error: TypeError: undefined is not an object (evaluating 'TestFairyBridge.begin')

I have this finally working on iOS after long hours of investigation:

Go to Build Phases -> Link Binary With Libraries, and select "libReactNativeTestFairy.a" More info here: https://stackoverflow.com/questions/39342002/react-native-undefined-is-not-an-object-evaluating-rni18n-locale#answer-45806929

@vijaysharm i suggest to add this step to Manual Installation steps here https://docs.testfairy.com/Platforms/React_Native.html

BartekPog commented 3 years ago

Has the issue been fully addressed?

I am having a similar issue while trying to run the app on Android using a machine running Ubuntu (thus the solution presented by @dmitryn is not satisfactory).

I am registering the app in a similar way as @ArtyEmsee presented and it results in the following error:

TypeError: null is not an object (evaluating 'TestFairyBridge.begin')

Unfortunately, I cannot provide any parts of the code as the project I am a part of is not open source.

animeshsinghweb commented 3 years ago

I guess just running npm install is not sufficient. We need to open the xcodeworkspace from /ios folder and drag and copy the node_modules/react-native-testfairy/ios (ios) folder to Library folder of the xcworkspace (create new files if necessary ticked). Then we need to install certain Frameworks as documented in the video https://youtu.be/HpLOsNwd_FM

Frameworks required

Also refer: https://docs.testfairy.com/Platforms/React_Native.html