How to run Expo test suite - react-native

I generated sample expo app, pull the latest https://github.com/expo/test-suite. I run test-suite in the simulator, it shows a spinner which never disappears.
Can you provide me an instruction how to run the tests?
I see some warnings as well while running test-suite.
Warning
Warning: Using unversioned Expo SDK. Do not publish until you set sdkVersion in exp.json
Warning
Warning: 'react' peer depencency missing. Run `npm ls` in /project/test-suite to see full warning.
If there is an issue running your project, please run `npm install` in /project/test-suite and restart.
Thanks

the repository that you linked is not a "test" suit as you understand it. It is not for testing your app. It exist for the developers of Expo as a tool, to test Expo before new releases of it.
Check out more about unit testing and test driven development;
https://en.wikipedia.org/wiki/Unit_testing
https://en.wikipedia.org/wiki/Development_testing
If your goal is to test your own app in you will need a simulator or a development device;
https://docs.expo.io/versions/v18.0.0/guides/up-and-running.html

Related

Why does my Expo app run in Expo Go but not as a development build?

I've created a development build of an Expo app using EAS. Previously I would open the app in Expo Go by running npx expo start and scanning the Metro Bundler QR code.
Now, when I try to do the same thing, Expo Go asks whether I want to open the project in Expo Go or as a "Development Build". It works fine in Expo Go, but crashes immediately when I attempt to open the dev build. The error reads:
null is not an object (evaluating '_ReanimatedModule.default.createNode')
This error is suspiciously similar to one that I encountered earlier in development, which I resolved by downgrading to React Native version 0.69.6. I'm also encountering a second error that says "'main' has not been registered", but I suspect this is downstream of the first error.
I have the same issue when I try to run the app with npx expo start --dev-client.
Any ideas why I might be having this problem?
It sounds like you may have run expo prebuild (https://docs.expo.dev/workflow/prebuild/) which removes "main": "node_modules/expo/AppEntry.js", from app.json. Try to create a new expo app and look at it's app.json file.
When you run expo prebuild it changes a few things with your project (see "side effects" in the prebuild docs).
I'm actually working through some issues with that right now too. I thought I had to run prebuild but turns out I didn't have to. Ever since I ran it my app will not load via the dev-client way. I can however switch back to npx expo start (NOT npx expo start --dev-client, see the scripts section of app.json as that is also changed when prebuild is run).
Let me know if you are able to get your app to load after re-adding the main stuff to app.json.
Ps, are you by chance using react-native-google-mobile-ads?

npx expo run:android -> CommandError: No development build (<package>) for this project is installed

After running npx expo run:android once, the app was pushed to the device and the app started up.
I then uninstalled the app on the device and then when I run npx expo run:android once again I get the error:
CommandError: No development build (<package-name>) for this project is installed. Please make and install a development build on the device first.
Learn more: https://docs.expo.dev/development/build/
I started another dummy project with another package name and the same thing can be reproduced after uninstalling once.
The built app is not installing once again on the Android device and then starting up.
The docs referenced in the error states https://docs.expo.dev/development/build/#locally-with-xcode-and-android-studio the following:
If you are comfortable setting up Xcode, Android Studio, and related dependencies, you can build and distribute your app the same as any other iOS or Android app.
The npx expo run commands will create a new build, install it on to your emulator or device, and start running it.
Not sure what I am doing wrong. Any help is appreciated.

Build command in detox

Looking at this doc: https://github.com/wix/Detox/blob/master/docs/APIRef.Configuration.md
It says that the
Build command (either xcodebuild, react-native run-ios, etc...), will
be later available through detox CLI tool.
I'm trying to setup the build command to work with Android. Am I supposed to add react-native run-android to the build command? What do they mean by Detox CLI tool?
The build field is optional, and should contain whichever execution logic needed in order to have the .apk file set and ready in the path specified in binaryPath. You are more than welcome to refer to the Detox example project, which was set up as a reference exactly for these type of questions.
In any case, from the react-native CLI tool's help: react-native run-android = builds your app and starts it on a connected Android emulator or device. That makes it not very suitable, as we typically want to build the app, and have detox launch the emulator (optional) and install the app on the device(s), as needed.

react-native android app quits before it launches (0.61.2) - couldn't find DSO to load: libhermes.so - Channel is unrecoverably broken

I have been trying to migrate from react-native 0.59.4 to 0.61.2.
After solving many many build and runtime problems on ios and android, this was the final problem before the successful launch of my react-native app on android. The app would build successfully but when it is time to launch on the emulator it would pop for a very brief moment then a white screen and application crashed with an app keeps crashing type of popup message. I can't even debug the app remotely on the chrome console since it doesn't launch in the first place.
Any ideas?
Note: This solution worked for my specific problem. To find out your problem try adb logcat *:E to see what is wrong in your case.
Ok, there is a very important command (I am on mac) that helps you see in the logs what is going on even if you can't launch the app on emulator: adb logcat *:E
In my case there were 2 main problems that caught my attention in the logs.
Channel is unrecoverably broken and will be disposed
and
couldn't find DSO to load: libhermes.so
Once I got these messages on my radar I started to dig/google for them.
After going through a lot of SO and GitHub topics here is what worked for me:
First, make sure you have made all the necessary modifications in your:
gradle.properties
app/build.gradle
android/build.gradle
package.json
etc
files (Use react-native upgrade helper to do this).
Then, if it is not installed already, do npm install jsc-android to install the required jsc package on your project.
Add the below in android/build.graddle inside allprojects -> repositories
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
Inside gradle.properties add
android.useAndroidX=true
android.enableJetifier=true
In some cases you may need to add below line to package.json
"postinstall": "npx jetify"
Also, in some cases it may help to replace the below line (dependencies section of app/build.gradle) with the exact version of the react-native you are using:
implementation "com.facebook.react:react-native:+"
Replace like so:
implementation "com.facebook.react:react-native:**0.61.2**"
I hope this helps to solve or at least make some progress with your problem.
Cheers.

In react-native, run minified code with debugging

I have an odd issue where I get the desired behavior when running a dev build but not a release one. I want to debug the code, but as far as I know I can't do that when running --configuration Release. I want to check if the issue has to do with minifying the js or something else. Is there a way to run
react-native run-ios --minify
or something? (The above command doesn't work. error: unknown option '--minify')
I've seen that you can run react-native bundle --minify, but I don't know how to then get the bundle onto the iOS Simulator, nor if bundle is the correct way to do things in React Native v0.42, as all the bundle solutions I've seen online have been v0.15ish.