Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we run Detox directly using apk/ipa independent of react-native app #3188

Closed
Avinash-Kannan opened this issue Jan 25, 2022 · 14 comments
Closed

Comments

@Avinash-Kannan
Copy link

Description

Problem Statement :

Our Project involves a requirement where we need to generate Artifact( apk/ipa) as part of Dev(react-native app) and use generated apk/ipa to run detox in emulator for QA independent of any react-native app.

Solution Needed!! :

We generated artifact(apk) and provided .apk file path in binaryPath in separate Detox -Jest project (not a react-native project). But we couldn’t run detox test successfully.
Kindly guide us on possible ways/ solutions to install apk/ipa directly and run scripts using Detox in emulators

Screenshot 2022-01-25 at 7 03 55 PM

Environment

  • Detox: 19.4.2
  • React : 17.0.2
  • React Native: 0.67.1
  • Node: 14.17.0
  • Device: Android & iOS
  • OS: latest
  • Test-runner : jest-circus
@Avinash-Kannan
Copy link
Author

Any help would be much appreciated. @noomorph @d4vidi @LeoNatan @rotemmiz

@noomorph
Copy link
Collaborator

Make sure to specify also testBinaryPath if your binaryPath location is custom: https://wix.github.io/Detox/docs/api/configuration/#apps-configurations

@mrbrentkelly
Copy link
Contributor

At Hudl we use the same pre-built APK (and androidTest APK) to run Detox Tests across multiple projects.

As suggested by @noomorph above you need to build an APK as well as an androidTest APK.

Your gradle command to generate these APKs would look something like this...

./gradlew clean assembleRelease assembleAndroidTest -DtestBuildType=release

This will result in 2 APKs being generated which you can then reference in your .detoxrc file...

"binaryPath": "path/to/your/apk/SomeApp.apk",
"testBinaryPath": "path/to/your/apk/SomeApp.apk-androidTest.apk"

For iOS you just need the .app that gets built as part of running something like the following command:

xcodebuild -quiet -workspace SomeApp.xcworkspace -scheme SomeApp -configuration Release -sdk iphonesimulator -derivedDataPath build/

Then you can reference the .app in your .detoxrc file...

"binaryPath": "path/to/your/app/SomeApp.app"

Hope that helps 😄 Also, I'm thinking this would have been a great Stack Overflow question as opposed to a Github issue 👍

@Avinash-Kannan
Copy link
Author

Thanks for your response @noomorph @mrbrentkelly .Yes, I can sense where we're going regarding Build configuration (Building app). Just forget the build part.

My question is : I have an app already (.apk / .ipa) . Now can i directly use this app and run detox test in simple detox project without dummy react-native project. ( refer screenshot attached above)

If possible , Guide me on steps.

@mrbrentkelly
Copy link
Contributor

Now can i directly use this app and run detox test in simple detox project without dummy react-native project

Yes you can. All you need to do is have Detox configured in your project.

Detox works in 2 parts; build and test. If you already have your Android APKs and iOS app created then you don't need to run the Detox build command. All you need to do is make sure your detoxrc file is pointed to the location of your app binaries, then run detox test --configuration <your configuration> e.g. detox test --configuration android.

@d4vidi
Copy link
Collaborator

d4vidi commented Jan 31, 2022

@Avinash-Kannan Generally, you can use Detox for testing using existing binary files (put in other words, detox build is just a convenience, not a mandatory phase). You did however mention that you do not have a react native project. Does that mean your app is a native Android/iOS app? If so, Detox will not work for you very well. As an alternative, you might want to consider a combination of Espresso and Detox Native for Android, and XCTest / EarlGrey for iOS.

Please close the issue if that answers your question.

@Avinash-Kannan
Copy link
Author

Thanks for your brief response @d4vidi .
My App is a react-native android/ios app. We generated artifacts (apk and ipa) out of it.
Now, my requirement is to create a separate e2e Detox project only using the generated (apk and ipa).

My question is, similar to Appium, can we use only the path of apk or ipa in detox to run e2e tests?

@d4vidi
Copy link
Collaborator

d4vidi commented Jan 31, 2022

In that case, the answer is yes. Here is a good example of that practice: demo-react-native-jest is yet another one of our example projects in the Detox mono-repo, which, as you can see in its detox.config.js, borrows the binaries from a different example project.

@stale
Copy link

stale bot commented Mar 6, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Mar 6, 2022
@stale
Copy link

stale bot commented Mar 13, 2022

The issue has been closed for inactivity.

@stale stale bot closed this as completed Mar 13, 2022
@dg-thor
Copy link

dg-thor commented Jan 31, 2024

getting error on running detox test The test APK could not be found at path: '/Users/axb/project-name/androidTest/project-name/

@dbaonguis-wfc
Copy link

In that case, the answer is yes. Here is a good example of that practice: demo-react-native-jest is yet another one of our example projects in the Detox mono-repo, which, as you can see in its detox.config.js, borrows the binaries from a different example project.

Hi @d4vidi, I can't find the example project.

@dbaonguis-wfc
Copy link

Avinash-Kannan

Hi @Avinash-Kannan I am looking for the same solution, are you able to setup a Detox test outside the react-native project?

@Patiljw1
Copy link

Hi @Avinash-Kannan , are you able to do the setup ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants